Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ggarrange: combine multiple plots

Tags:

r

enter image description here

The attached picture is from the following article and is using ggarrange to merge those plots: http://www.sthda.com/english/articles/24-ggpubr-publication-ready-plots/81-ggplot2-easy-way-to-mix-multiple-graphs-on-the-same-page/

ggarrange(sp,                                                 # First row with scatter plot
          ggarrange(bxp, dp, ncol = 2, labels = c("B", "C")), # Second row with box and dot plots
          nrow = 2, 
          labels = "A"                                        # Labels of the scatter plot
          ) 

I would like to create the same plot, but instead of having two smaller plots in the bottom and a larger one on the top, I would like to inverse it: Two small plots (A and B) on the top and a larger plot C in the bottom

I tried using the following code with no success:

ggarrange(
  plot1, plot2,           
  ggarrange(plot3, nrow = 2, labels = c("C")), 
  ncol = 2, 
  labels = c("A","B")       
) 

With this code I just see plot3 in the top left corner.

like image 216
Ttam Avatar asked Sep 05 '25 16:09

Ttam


1 Answers

The patchwork package makes this stuff a bit easier

library(patchwork)
(plot1 | plot2) / plot3 + plot_annotation(tag_levels ="A")
like image 169
MrFlick Avatar answered Sep 07 '25 09:09

MrFlick