如何使用rworldmap叠加两个图?

oymdgrw7  于 2023-11-14  发布在  其他
关注(0)|答案(1)|浏览(101)

嗨,我想用rworldmap覆盖两个世界Map,但吹代码不工作,它只显示map2。有人能帮助我吗?

library(rworldmap)
data(countryExData)

sPDF <- joinCountryData2Map(countryExData
                             , joinCode="ISO3"
                             , nameJoinColumn="ISO3V10")

#map1
mapDevice()
map1 <- mapCountryData(sPDF, nameColumnToPlot='BIODIVERSITY')

#map2
map1 + mapBubbles(sPDF, nameZSize="ECOSYSTEM")

字符串

0md85ypi

0md85ypi1#

你可以在绘制完第一张Map后调用par(new = TRUE)。然后第二张Map将被绘制在顶部。有关详细信息,请参阅documentation
更新代码:

library(rworldmap)
data(countryExData)

sPDF <- joinCountryData2Map(countryExData,
                            joinCode = "ISO3",
                            nameJoinColumn = "ISO3V10")

#map1
mapDevice()
mapCountryData(sPDF, nameColumnToPlot = 'BIODIVERSITY')

# draw next frame as if it were on a new device
par(new=TRUE)

#map2
mapBubbles(sPDF, nameZSize = "ECOSYSTEM")

字符串

相关问题