Overlaying R county map onto a state map

半城伤御伤魂 提交于 2019-12-19 03:37:16

问题


R newbie here.

If I first use map('state'), how can I then use map('county', ylim=..., xlim=...) but offset it like this:

Right now, I am using imagemagick's composite -gravity southwest ... to combine 2 PNG files, but this seems less than ideal.


回答1:


You can use the fig option in a graphics parameter call to set the region where a figure will be plotted.

map("state")
par(fig=c(0.1,0.9,0,0.6), new=TRUE, xpd=NA)
map("county",regions="california",add=TRUE)

In regards to the other code, xpd=NA lets you plot in the margins of a plot while new=TRUE makes sure you don't scrap the existing plot when starting a new plot. Adding add=TRUE to the end of the plot for the county acts similarly to the new=TRUE call.



来源:https://stackoverflow.com/questions/10369253/overlaying-r-county-map-onto-a-state-map

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!