Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strip.placement = "outside" and strip.switch.pad.wrap don't work together perfectly for facet_wrap. #5935

Open
junjunlab opened this issue Jun 5, 2024 · 2 comments · May be fixed by #5958

Comments

@junjunlab
Copy link

strip.switch.pad.wrap doesn't work when strip.placement = "outside" and strip.position = "bottom":

library(ggplot2)
base <- ggplot(mtcars, aes(mpg, drat)) +
  geom_point()

base + facet_wrap(~cyl) +
  theme(strip.placement = "outside",
        strip.switch.pad.wrap = unit(0.1,"npc"))

image

strip will only be added on one panel when strip.position = "bottom/left":

base + facet_wrap(~cyl,strip.position = "bottom",
                  ncol = 2) +
  theme(strip.placement = "outside",
        strip.switch.pad.wrap = unit(0.1,"npc"))

image

base + facet_wrap(~cyl,strip.position = "left") +
  theme(strip.placement = "outside",
        strip.switch.pad.wrap = unit(0.1,"npc"))

image

It doesn't work when strip.position = "right":

base + facet_wrap(~cyl,strip.position = "right") +
  theme(strip.placement = "outside",
        strip.switch.pad.wrap = unit(0.1,"npc"))

image

@teunbrand
Copy link
Collaborator

Arguably, it does work as documented in strip.switch.pad.wrap (emphasis mine):

space between strips and axes when strips are switched (unit); inherits from spacing.

So if there is no axis, there is no padding.

I can imagine a need for spacing between the panel and the strip, regardless of the presence of an axis.
But I think that should probably be a separate theme element from strip.switch.pad.wrap and apply both to facet_wrap() and facet_grid().

Slightly off-topic; I don't know why there is a separate wrap/grid argument for the padding. You can't ever build a plot with both wrap and grid facetting, so they're mutually exclusive.

@junjunlab
Copy link
Author

I got it, the padding only works when presence of an axis. Thanks, maybe it's a little need for some peole.

@teunbrand teunbrand linked a pull request Jun 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants