Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Patchwork not following layout correctly

I want four equally sized panels on the second row of my plot but the output is not matching the layout I specify.

library(ggplot2)
library(patchwork)

set.seed(1)
df<-data.frame(x=rnorm(10),y=rnorm(10))
p <- ggplot(df, aes(x=x,y=y)) +
  geom_point()

layout <- "
AAABBBBB
CCDDEEFF
"

p + p + p + p + p + p + plot_layout(design = layout)

enter image description here

like image 981
slabofguinness Avatar asked Aug 30 '25 17:08

slabofguinness


1 Answers

This will produce the correct output (adapted from here)

(p + p + plot_layout(widths = c(3,5))) /
  (p + p + p +p + plot_layout(widths = c(2,2,2,2)))
like image 172
slabofguinness Avatar answered Sep 02 '25 07:09

slabofguinness