I am trying to combine n number of barplots with one common label plot at the bottom. My problem is that grid.arrange combines the two plots in 50%-50%. I am looking for som
grid.arrange(plot1, plot2, widths=c(0.7, 0.3), ncol=2)
sorry for your example:
grid.arrange(plot1, plot2, heights=c(0.7, 0.3), nrow=2)
EDIT - for spacing between plots:
blank<-rectGrob(gp=gpar(col="white")) # make a white spacer grob
grid.arrange(plot1, blank, plot2, heights=c(0.7, 0.05, 0.25), nrow=3)
grid.arrange() won't let you align the panels properly, it's better to work with gtable.
require(gtable)
g1 <- ggplotGrob(plot1)
g2 <- ggplotGrob(plot2)
## add dummy column for missing strips
g2 <- gtable_add_cols(g2, unit(0,"mm"))
## merge, basing widths on g1
g <- gtable:::rbind_gtable(g1, g2, "first")
## add spacing
g <- gtable_add_rows(g, unit(1,"cm"), pos=nrow(g1))
grid.newpage()
grid.draw(g)
Note that the panel heights are equal by default with this strategy. That's because they appear as unit(1, "null")
in the layout (g$heights
). It's trivial to edit g$heights
if another ratio is required.