我需要安排两个分面图,如下:
d = data.frame(Index = LETTERS[1:5],x=1:5,y=1:5)
A = ggplot(subset(d,Index == 'A'),aes(x,y)) +
theme_bw() +
theme(axis.title.x = element_blank()) +
geom_point() + facet_wrap(~Index) + labs(title = "Title, The Title",
subtitle = "Subtitle, The Subtitle",
y = "Side Axes")
B = ggplot(subset(d,Index != 'A'),aes(x,y)) +
theme_bw() +
theme(axis.title.x = element_blank(), axis.title.y = element_blank()) +
geom_point() + facet_wrap(~Index) + labs(title = "", subtitle = "")
g = gridExtra::arrangeGrob(A,B,ncol=2,bottom="Bottom Axes")
grid.arrange(g)
这将产生以下结果:
从上面可以看出,图形区域的顶部边缘存在轻微的不对齐。这是由标题和副标题中的“逗号”引起的。
有人知道我如何强制使顶部边缘对齐吗?我需要在左侧图形上有一个标题和副标题,并在右侧图形上有一个(空)标题和副标题。
theme(plot.margin = unit(c(.3, .2, .15, .2), 'cm'))
。 - alistaire