Since ggplot2 4.0.0 it is possible to generate plots with absolute dimensions using theme(panel.widths, panel.heights)
When feeding those plots into patchwork, one runs into some unexpected results. Here are some examples:
library(ggplot2)
library(patchwork)
p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp)) +
theme(panel.widths = unit(30, "mm"), panel.heights = unit(30, "mm"))
p2 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear)) +
theme(panel.widths = unit(30, "mm"), panel.heights = unit(30, "mm"))
p3 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear)) +
facet_wrap(vars(gear)) +
theme(panel.widths = unit(30, "mm"), panel.heights = unit(30, "mm"))
p1 + p2 # looks good
p1 / p2 # looks good
p1 | p2 # looks good
(p1 | p2) / (p2 + p1) # vertical spacing dynamic instead of fixed
(p1 | p2) / p1 # bottom plot looses its absolute width
p1 + p3 # unexpected
p1 / p3 # looks good
p1 | p3 # unexpected
(p1 | p3) / (p3 + p1) # unexpected
(p1 | p3) / p1 # unexpected
Sorry for bringing up this potentially unpleasant topic 🫣
Best wishes
Broder