ggplot objects can be passed in. If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE), then plot 1 will go in the upper left, 2 will go in the upper right, and 3 will go all the way across the bottom.

multiplot(..., plotlist = NULL, file, cols = 1, layout = NULL)



`ggplot` objects


list of `ggplot` objects


A matrix specifying the layout. If present, 'cols' is ignored.


Number of columns in layout


multiplot(g, g2, g3)
Make a list from the ... arguments and plotlist
If layout is NULL, then use 'cols' to determine layout
Make the panel
ncol: Number of columns of plots
nrow: Number of rows needed, calculated from #' of cols
Set up the page
Make each plot, in the correct location
Get the i,j matrix positions of the regions that contain this subplot