I am attempting to use grobs and gtable to arrange 4 (ggplot2) plots into a 2x2 grid. I don\'t know how to set widths, and also a non- 1xn, or nx1 arrangement.
Using thi
Pretty similar to the above, but using gtable functions*
library(ggplot2)
pl <- list(ggplot() + xlab("x"),
ggplot() + ylab("y"),
ggplot() + ylab("y"),
ggplot() + ggtitle("title") + xlab("x"))
library(grid)
library(gridExtra)
gl <- lapply(pl, ggplotGrob)
# gt <- cbind(rbind(gl[[1]], gl[[3]]),
# rbind(gl[[2]], gl[[4]]))
# alternative to remove x-axes of top row of plots
gt <- cbind(rbind(gl[[1]][1:3,], gl[[3]]),
rbind(gl[[2]][1:3,], gl[[4]]))
grid.newpage()
grid.draw(gt)
*: actually, since gtable doesn't allow the use of pmax when comparing units, this is using a drop-in replacement from the dev version of gridExtra.