Skip to content
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

guide_colorsteps() missbehaving with discrete values after 3.5.0 #5786

Closed
eliocamp opened this issue Mar 20, 2024 · 2 comments
Closed

guide_colorsteps() missbehaving with discrete values after 3.5.0 #5786

eliocamp opened this issue Mar 20, 2024 · 2 comments

Comments

@eliocamp
Copy link
Contributor

In the previous ggplot2 version (3.4.4) guide_colorsteps() would behave reasonably for discrete values:

library(ggplot2)
levels <- pretty(range(volcano))

volcano2 <- reshape2::melt(volcano) |> 
  transform(value_discrete = cut(value, 
                                 breaks = levels,
                                 ordered_result = TRUE))


ggplot(volcano2,  aes(Var1, Var2)) +
  geom_raster(aes(fill = value_discrete)) +
  guides(fill = guide_colorsteps())

Created on 2024-03-20 with reprex v2.0.2

In ggplot2 3.5.0, the guide is all wonky and in the wrong order:

library(ggplot2)
levels <- pretty(range(volcano))

volcano2 <- reshape2::melt(volcano) |> 
  transform(value_discrete = cut(value, 
                                 breaks = levels,
                                 ordered_result = TRUE))


ggplot(volcano2,  aes(Var1, Var2)) +
  geom_raster(aes(fill = value_discrete)) +
  guides(fill = guide_colorsteps())

This might be something to do with the new guide system.

@teunbrand
Copy link
Collaborator

Thanks for the report Elio! This was reported before in #5757 and should be fixed in the development version. We plan on releasing a hotfix for the issues caused by 3.5.0 once we have a good idea what bugs it may have caused for people.

@eliocamp
Copy link
Contributor Author

Oh, my apologies for the duplicate issue. Thanks!

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

No branches or pull requests

2 participants