Skip to content

Allow clipping in facet labels #3684

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

Closed
malcolmbarrett opened this issue Dec 20, 2019 · 4 comments
Closed

Allow clipping in facet labels #3684

malcolmbarrett opened this issue Dec 20, 2019 · 4 comments
Labels
facets 💎 feature a feature request or enhancement

Comments

@malcolmbarrett
Copy link
Contributor

malcolmbarrett commented Dec 20, 2019

By default, ggplot2 reasonably clips long facet labels. While this can be turned off by manipulating the underlying grobs, it would be nice for some circumstances if you could set clip = "off" in a related ggplot2 function, as you can in the coord_*() functions.

library(ggplot2)
iris$Species <- factor(
  iris$Species, 
  labels = c(
    "Here is a pretty long label that might not make it, if we're being totally honest", 
    "here's a shorter one", 
    "shorter yet"
  )
)

ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
  geom_point() + 
  facet_wrap(vars(Species))

Created on 2019-12-20 by the reprex package (v0.3.0)

@thomasp85
Copy link
Member

It would be quite easy to make this a theme setting (I have just fiddled with that code in another matter). What say the @clauswilke, @hadley, do you have any objections to this?

@clauswilke
Copy link
Member

I think it's a good idea.

@thomasp85
Copy link
Member

This change intersects with #3683 so I'll wait for that to get merged

@thomasp85 thomasp85 added facets 💎 feature a feature request or enhancement labels Jan 21, 2020
@teunbrand
Copy link
Collaborator

This is fixed by #4223, though the long label is obscured on the right by the strip background of the middle panel.

library(ggplot2)
iris$Species <- factor(
  iris$Species, 
  labels = c(
    "Here is a pretty long label that might not make it, if we're being totally honest", 
    "here's a shorter one", 
    "shorter yet"
  )
)

ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
  geom_point() + 
  facet_wrap(vars(Species)) +
  theme(strip.clip = "off")

Created on 2022-05-20 by the reprex package (v2.0.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
facets 💎 feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

5 participants