thomasp85 / patchwork

The Composer of ggplots
https://patchwork.data-imaginist.com
Other
2.42k stars 157 forks source link

collecting axis titles does not work when using more complex designs #349

Closed n-kall closed 6 days ago

n-kall commented 5 months ago

The following works:

library(ggplot2)
library(patchwork)

p1 <- ggplot(mtcars) +
  geom_point(aes(mpg, disp)) +
  labs(y = "mpg", x = "collected axis title")

p2 <- ggplot(mtcars) +
  geom_boxplot(aes(gear, disp, group = gear)) +
  labs(y = "gear", x = "collected axis title")

p1 + p2 + plot_layout(axis_titles = "collect", design = "AB")

pwork1

but changing the design leads to the axis collection no longer happening

p1 + p2 + plot_layout(axis_titles = "collect", design = "AAB")

pwrk

p1 + p2 + plot_layout(axis_titles = "collect", design = "AABB")

pwork2

wagnnerms97 commented 5 months ago

axes = "collect" and axis_titles = "collect" it also doesn't work when using coord_equal

image

image

teunbrand commented 5 months ago

With regards to the coord_equal() thingy, the axis/title merging does not seem to work there because the axes appear to be nested alongside panels and don't have the usual grob names.