-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Facet strip rendering order and metadata #2769
Comments
Irrespective of any implementation issues, I don’t entirely understand how this is meant to work for |
I was thinking something like... let's say we have a 3x3 facet layout:
The column facet labels could be prefixed "(a, d, g)", "(b, e, h)", "(c, f, i)" and the row labels could be prefixed "(a–c)", "(d–f)", "(g–i)". Although, now that I think about it, that might not make sense to the reader if the individual facets aren't also labelled. This might require some more thought on my part 😆 |
In my mind, a grid is a two-dimensional display and needs two-dimensional labeling, as I described. You could start with that approach and see where it goes. |
I think you might be right. Thanks for lending me your thoughts, @clauswilke! |
I'm closing this issue. Please open a new one if 2D labeling requires changes to the faceting code. |
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/ |
I created a small package to help with facet labelling, and one of the neat things it can do is number or letter facets created with
facet_wrap
, so that you can refer to them individually in papers and reports.I'd love to do the same for
facet_grid
(for example, have labels prefixed with "(a–c)", "(d–f)", etc), but there's a difficult limitation here that I've outlined here. Essentially, the labelling function doesn't get enough information to make this possible withfacet_grid
, as far as I can tell.One solution would be to change the order in which facet strips are rendered in
ggplot2::render_strips
. It currently looks like this:If rows were done first instead, I could take advantage of the fact that my labelling function is a closure and store the information learned about the number of rows in the outer function, so that the inner function could access it later when doing columns. If you just flipped the two lines around, that would probably be a destructive change, but you could easily call y, then x, then put them in a list.
Another, potentially less destructive, solution would be to simply attach more metadata to the data frame given to the labelling function. If the data frame had a list attached, where each element was a numeric vector of the facet numbers, this would be pretty trivial to implement. It would also catch the corner case where facet levels are dropped in
facet_grid
due to lack of data (the other solution would have to assume that all facets were present).Would either of these changes to ggplot2 be feasible? Happy to submit a PR myself if it's an acceptable change.
The text was updated successfully, but these errors were encountered: