-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Palettes for discrete scales #5771
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
Conversation
@@ -116,6 +116,6 @@ test_that("expand_limits_scale_discrete() begrudgingly handles numeric limits", | |||
coord_limits = c(NA, NA), | |||
range_continuous = c(-15, -2) | |||
), | |||
c(-15, -2) | |||
c(-16, -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've put the palettes in line with palletes elsewhere in that they now require an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I dislike the palette
name for this functionality, but I guess this is in line with the terminology we have ended up with
Yeah I also don't think it is a great name, but it is consistent with the rest of the scales api |
Merge branch 'main' into discrete_palette # Conflicts: # R/scale-discrete-.R
This PR aims to fix #5770.
Briefly, it adds a
palette
argument to discrete scales that can be used to customise the position discrete variables are placed in.Demonstrations perhaps show off the functionality better than text descriptions.
The reprex from the issue works:
You can use the palette to invert the order:
If two limits share a position, position adjustments treat these like a single position (invoking dodging in the example) but axis guides show duplicated labels.
Invalid palette output is checked:
When mixing the discrete scale with continuous values in a different layer;
The continuous values stay as-is
Created on 2024-03-12 with reprex v2.1.0
There are at this moment two outstanding issues:
palette
functions that taken
as argument. In this PR, palette functions take the limits as arguments. Should I let palettes taken
as an argument instead? I think the benefit of the current approach is that one could design a lookup table aspalette
argument.