Skip to content

Wrong mapping provided to limits that include NA #5756

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

Closed
teunbrand opened this issue Mar 7, 2024 · 0 comments · Fixed by #5848
Closed

Wrong mapping provided to limits that include NA #5756

teunbrand opened this issue Mar 7, 2024 · 0 comments · Fixed by #5848
Labels
bug an unexpected problem or unintended behavior scales 🐍

Comments

@teunbrand
Copy link
Collaborator

Briefly, when including NA in the limits, I interpret that as wanting to display the na.value for it.
This is fine (aside from #5749 (comment)).

library(ggplot2)

p <- ggplot(mpg, aes(displ, hwy, colour = factor(cyl))) +
  geom_point()

p + scale_colour_discrete(limits = c("4", "5", "6", NA))

However when you don't have NA as the last limit, anything after it gets the wrong mapping.
The cyl == 8 data become grey instead of blue.

p + scale_colour_discrete(limits = c("4", "5", NA, "8"))

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior scales 🐍
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant