Overlaying R county map onto a state map

后端 未结 1 1328
[愿得一人]
[愿得一人] 2021-01-06 05:26

R newbie here.

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

相关标签:
1条回答
  • 2021-01-06 05:53

    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.

    enter image description here

    0 讨论(0)
提交回复
热议问题