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
Allow parsing expressions in facet_wrap #656
Conversation
Some useful examples: m <- mpg
levels(m$drv) <- paste("Y[", 1:3, "]", sep="")
p <- ggplot(m, aes(x = displ, y = cty)) + geom_point()
p + facet_wrap(~drv, labeller = label_parsed)
p + facet_wrap(~drv+fl, labeller = label_parsed)
p + facet_wrap(~drv)
p + facet_wrap(~drv+fl)
p + facet_wrap(~drv+fl, labeller = label_both) |
That doesn't work with multiple factors because "," is not a possible plotmath expression. I fixed it but I'm not sure how submit it. |
See here: Although it may be a bit more complicated since you're making a modification of my branch, instead of Hadley's master branch. If that ends up being too much trouble, you can just cut/paste the patch here. |
I think its better to use an expression list, which separates the expressions with commas - see my latest commit. It will render the example you provided, with commas: p + facet_wrap(~drv+fl, labeller = label_parsed) It might be better to add a new labeler function to scales that makes a list automatically. |
The problem is in I think the way to do this is to first loop over all the layers with |
The problem with this approach is that it doesn't allow for other labeller functions. To really fix this we need a more flexible specification of labeller functions - they should take a matrix (or other richer data structure) as an argument. But this will mean that we need to rewrite the existing labeller functions and hence is an API breaking change, which means we need to push it off to a future version. |
This is making me sad... +1 for future version feature request. Thanks! |
Same here. This doesn't seem to have been fixed. writing a (variable-specific) labeler function every time I'd like to relabel facets seems tedious. Sorry, if this has been fixed and I missed it. cheers. |
This sounds like a great feature, but unfortunately we don't currently have the development bandwidth to support it. If you'd like to submit a pull request that implements this feature, please follow the instructions in the development vignette. |
Hello, I tried Winston's patch and it seems fully functional, on par with facet_grid's labeller. |
@hadley what was the problem with this labeller exactly? last time I tried it it seemed to work fine. If it works in most situations, maybe it'd still be nice to have it with informative error messages when it doesn't work. |
@lionel- I don't remember. If you want to do a fresh PR now is a good time. |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Fixes #25.
This should have visual tests before it's merged.