introduced scale_position_*(reverse=True) #254
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces a parameter 'reverse' to scale_x/y_continuous and scale_x/y_discrete,
which turns the scale around.
This is similar to scale_x/y_reverse, but works on transformed and discrete scales,
and fixes #253.
Both were doable before, just not easily - you'd have to define your own transformation,
and turn your discrete data into a Categorical with reversed categories.
I believe this hits the right abstraction and keeps compatibility with ggplot2.
scale_x/y_reverse are now wrappers around scale_x/y_continuous(reverse=True, *args, **kwargs).
For the continuous case, this is 'easy'
we simply define a transformation based on the existing one with * -1 at the right places and fiddle with the limits a bit to generate the same breaks.
reverse_transform() function should probably move to mizani though. @has2k1 you're in a better position to make this happen than I am.
For the discrete case this original looked like an easy case of reversing the mapping in scale_position.discrete for both discrete and continuous data, but it turns out that is being called twice from draw and that was relying on the continuous data being identity mapped.
The flow was like this:
This causes issues when you add in a geom that has continuous data - for example a hline,
since that data needs mapping, but only once (or we'd be back at the start again).
I think I've nailed it with a guard in layout.map_position - if not we're lacking a test case to expose it...
I've also included the doc changes suggested in #253 (and of course the doc for reverse=)