patchwork icon indicating copy to clipboard operation
patchwork copied to clipboard

axis_titles = "collect" does not work when modifying panel grid

Open gevro opened this issue 5 months ago • 2 comments

axis_titles = "collect" does not work when modifying panel grid

For example when adding theme(panel.grid.major.x = element_blank())

gevro avatar Nov 11 '25 20:11 gevro

Could you provide a reproducible example? I tried to replicate your issue, but I wasn't able to do so. In the simple example below, for example, the axis titles are still collected even after the grid lines have been removed from one plot.

library(ggplot2)
library(patchwork)

packageVersion("ggplot2")
#> [1] '4.0.1'
packageVersion("patchwork")
#> [1] '1.3.2'

p1 <- ggplot(mtcars) +
  geom_bar(aes(gear)) +
  theme(panel.grid.major.x = element_blank())

p2 <- ggplot(mtcars) +
  geom_boxplot(aes(gear, disp, group = gear))

p1 + p2 +
  plot_layout(axis_titles = "collect")

Created on 2025-11-29 with reprex v2.1.1

trekonom avatar Nov 29 '25 22:11 trekonom

Your example indeed works. I can't quite figure out why in my code it is not working. I will keep trying to make a reproducible example.

gevro avatar Nov 30 '25 03:11 gevro