我在对齐两个地图时遇到了困难。以下是使用可重复示例:
library(ggplot2)
library(cowplot)
world <- map_data("world")
pl2= ggplot() +
geom_polygon(data=world, aes(x=long, y=lat, group=group)) +
theme_bw()+
coord_equal()
pl1 <- ggplot() +
geom_polygon(data=world, aes(x=long, y=lat, group=group, color=group)) +
coord_equal()
plot_grid(pl2, pl1 + theme(legend.justification = c(0,1)), align="h",axis = "bt")
我尝试了各种方法,如设置图形的宽度和高度,尝试使用
scale=
,从 align="h",axis = "bt"
中选择不同的选项。我还尝试了 plot_grid(pl2, pl1+ theme(legend.position = "none"), align="h", scale=c(1,1))
然后再次使用 plot_grid
添加 legend legend <- get_legend(pl1)
。
当我使用coord_equal时,也会出现大量空白,但我无法去除它(我不保存图形,只是显示它)。