Skip to content

Only sort numeric breaks in binned guides #5758

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

Merged
merged 4 commits into from
Mar 18, 2024
Merged

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5757.

Briefly, guides try to parse bins from the break information in a scale. To fix #5152, we automatically sorted the breaks. However, that should only happen for numeric breaks. This PR moves the sorting step to apply to numeric breaks only.

Reprex from issue:

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2

ggplot(mtcars, aes(mpg, drat, colour = cut(disp, c(90, 200, 300, 400, 500)))) +
  geom_point() +
  scale_colour_viridis_d(guide = guide_colorsteps())
#> Warning: Removed 4 rows containing missing values or values outside the scale range
#> (`geom_point()`).

Created on 2024-03-07 with reprex v2.1.0

@teunbrand teunbrand added this to the ggplot2 3.5.1 milestone Mar 7, 2024
Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand teunbrand merged commit 7a393da into tidyverse:main Mar 18, 2024
@teunbrand teunbrand deleted the cut_bins branch March 18, 2024 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

guide_colorsteps() from new ggplot2 version Unsorted breaks in guide_coloursteps()
2 participants