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
Palettes for discrete scales #5771
Open
teunbrand
wants to merge
7
commits into
tidyverse:main
Choose a base branch
from
teunbrand:discrete_palette
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
teunbrand
commented
Mar 12, 2024
@@ -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 |
teunbrand
changed the title
WIP: palettes for discrete scales
Palettes for discrete scales
Mar 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #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.