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 PR aims to fix #3171.
Briefly, it adds a
sec.axis
option forscale_{x/y}_discrete()
.For context:
The secondary axis system is not ideal. We have tried to move that functionality to guides in #5410, but it becomes too complicated. Because it doesn't seem viable to handle this functionality in guides, I think it is time to implement secondary axes for discrete scales.
In some more detail:
It currently only accepts identity transformations, as it just doesn't make sense to me why one would transform a discrete axis.
This also means that
dup_axis()
should be preferred tosec_axis()
for discrete scales.Breaks can be given as numeric that can take arbitrary positions, or as discrete breaks that can take one of the limits values.
For discrete scales, breaks are mapped early on in
AxisSecondary$break_info()
.An example plot with relabelling the x-axis and numeric positions in the y-axis:
Created on 2024-01-02 with reprex v2.0.2