问题
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