将R县地图叠加到州地图上 [英] Overlaying R county map onto a state map
问题描述
R新手在这里.
如果我第一次使用map('state')
,那么我该如何使用map('county', ylim=..., xlim=...)
但要像这样补偿它:
If I first use map('state')
, how can I then use map('county', ylim=..., xlim=...)
but offset it like this:
现在,我正在使用imagemagick的composite -gravity southwest ...
合并2个PNG文件,但这似乎不理想.
Right now, I am using imagemagick's composite -gravity southwest ...
to combine 2 PNG files, but this seems less than ideal.
推荐答案
您可以在图形参数调用中使用fig
选项来设置绘制图形的区域.
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)
关于其他代码,xpd=NA
使您可以在图的边缘进行绘图,而new=TRUE
确保在开始新图时不会废弃现有图.在县的情节末尾添加add=TRUE
的行为与new=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.
这篇关于将R县地图叠加到州地图上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!