我正在尝试将美国地图拆分为多个窗口(其中一些窗口包含两次相同的州)。我希望比例保持不变(这样地图不会扭曲),但也要尽量减少地图之间的空间。我不能使用 facet_wrap (由于区域的重叠性质——无论如何, facet_wrap 不能有固定的比例并且每个窗口都有不同的 xlims)。关于如何改善结果间距的任何建议?
require(data.table)
require(ggplot2)
require(maps)
require(gridExtra)
all_states <- as.data.table(map_data("state"))
setnames(all_states,"region","state")
##define regions with overlapping states
weco.states <- c("oregon","washington","california")
west.states <- c("washington","montana", "idaho","utah","nevada","arizona","new mexico",
"wyoming","colorado","south dakota","texas")
east.states <- c(setdiff(unique(all_states$state), union(weco.states,west.states)),
"texas","south dakota")
all_states[,c("weco","west","east"):=FALSE]
all_states[state%in% weco.states, weco:=TRUE]
all_states[state%in% west.states, west:=TRUE]
all_states[state%in% east.states, east:=TRUE]
p.regbase <- ggplot() + coord_equal() +ylim(c(25,50))
p.weco <- p.regbase + geom_polygon(data=all_states[(weco),], aes(x=long, y=lat, group = group),colour="white", fill="grey" )
p.west <- p.regbase + geom_polygon(data=all_states[(west),], aes(x=long, y=lat, group = group),colour="white", fill="grey" )
p.east <- p.regbase + geom_polygon(data=all_states[(east),], aes(x=long, y=lat, group = group),colour="white", fill="grey" )
print(arrangeGrob(p.weco,p.west,p.east,ncol=3,nrow=1))
根据我在 Windows GUI 中调整图形窗口大小的方式,结果要么不好(比例不同)
或体面(相同高度)但空间太大:我怎样才能摆脱多余的空间?