如何使用arrangeGrob控制行之间的填充?

时间:2017-08-15 19:08:19

标签: r ggplot2 gridextra

使用gridextraggplot2时如何控制行之间的填充?我看到我的最终情节的两行之间有一些很大的差距。即使在使用padding参数进行播放时也具有最小值......

p1 <- ...
p2 <- ...
p3 <- ...
final <- gridExtra::arrangeGrob(p1, p2, p3, layout_matrix = rbind(c(1,2), c(3,3)), heights=c(3,7), 
                                padding = unit(0.1, "line"))
ggplot2::ggsave(filename=output.file,plot=final,width=18,height=9)

1 个答案:

答案 0 :(得分:2)

padding参数用于注释(标题等)。图之间的间距应通过图边距调整,

pl <- replicate(3, ggplot(), FALSE)

pl <- lapply(pl, function(p) p + theme(plot.margin = margin(t=50, l=50)))

gridExtra::grid.arrange(grobs = pl, layout_matrix = rbind(c(1,2), c(3,3)), heights=c(3,7))

enter image description here