You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In many scenarios across aesthetics (x, y, fill, colour, and probably anything discrete), it would help to have the option to reverse factor levels on a discrete axis.
What would you think of a PR for one of the options below?
However this is implemented, it would also propagate to a change in the scales package. I think that the simplest change would be to make a scales::reverse_trans_discrete() function, but I've not fully dived in to confirm that.
I think that the simplest and least invasive change would be to add a reverse argument to all the scale_*_discrete() and similar categorical functions (e.g. scale_colour_hue() and scale_colour_viridis_d()). With reverse=TRUE, scales::reverse_trans_discrete() would be used.
The PR seems like it would be a good fit if applied to discrete scales (and it would help to add that to the documentation with a reversing example, too).
Having discrete position scales support functions as the limits argument seems like a reasonable solution to this. All other scales allow this (discrete and continuous). Then you could do limits = rev:
Activity
clauswilke commentedon Feb 3, 2019
Maybe one option would be to allow functions as limit arguments, just like we do for labels?
Created on 2019-02-03 by the reprex package (v0.2.1)
clauswilke commentedon Feb 3, 2019
There's an old (abandoned?) PR about a similar topic for continuous scales: #2334
billdenney commentedon Feb 3, 2019
The PR seems like it would be a good fit if applied to discrete scales (and it would help to add that to the documentation with a reversing example, too).
hadley commentedon Jun 25, 2019
Note that the colour scales have a
directionargument which this could replace.paleolimbot commentedon Jun 25, 2019
Having discrete position scales support functions as the
limitsargument seems like a reasonable solution to this. All other scales allow this (discrete and continuous). Then you could dolimits = rev:Created on 2019-06-25 by the reprex package (v0.2.1)
The code that needs to be updated is here:
ggplot2/R/scale-discrete-.r
Lines 81 to 85 in e2bdf85
billdenney commentedon Jun 25, 2019
@paleolimbot, That seems like a great solution that would allow simple generalization across this and other solutions.
Allowed reversing of discrete position scales (#3426, fixes #3115)
lock commentedon Jan 12, 2020
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/