Search code examples
rggplot2panelpar

Make a multiple panel structure to insert graphs of different sizes afterwards (16 in total)


I made 15 pie charts, and one line chart.

My goal is now to line them up according to the structure on the picture

enter image description here

Is there a way like

par(mfrow=c(2,2))

to build such a structure, in which I can afterwards plot all the graphs I made? Accept that in this case, I would like to be able to determine the sizes of the plots.


Solution

  • try this,

    library(gridExtra)
    library(grid)
    l <- cbind(c(5:1, NA), rbind(6:10, matrix(16, 5, 5)), c(11:15, NA))
    
    # dummy placeholders for illustration
    plots <- lapply(1:16, function(ii) 
                grobTree(rectGrob(), textGrob(paste("plot", ii))))
    
    grid.arrange(grobs=plots, layout_matrix=l)
    

    enter image description here

    for actual plots, try

     plots <- replicate(16, ggplot(), simplify = FALSE)
    

    or a list of your 16 plots (or grid grobs),

    enter image description here