`strip.switch.pad.grid` in `ggplot2` can not work

Hello, I have some problems about strip.switch.pad.grid in ggplot2. I use strip.switch.pad.grid = unit(2, "cm") , but it doesn't seem to be working. The following is figure p1.

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.1.3
p <- ggplot(mpg, aes(displ, cty)) + geom_point() 
p1 <- p +
  facet_grid(vars(drv), vars(cyl)) +
  theme(strip.switch.pad.grid = unit(2, "cm"), strip.placement = "outside")
# print(p1)

Created on 2023-08-04 with reprex v2.0.2

strip.switch.pad.grid is effective only when you are switching the strip axis so one of the 3 switch options would need to be set. here is one example

p1 <- p +
  facet_grid(vars(drv), vars(cyl),
             switch = 'both') +
  theme(strip.switch.pad.grid = unit(2, "cm"), strip.placement = "outside")
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.