Skip to content

Prevent mismapping when limits contain NA in non-last position #5848

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 6 commits into from
Apr 29, 2024

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5756.

Briefly, it simply drops NA from limits before mapping, ensuring that only 'proper' values are matched.

Reprex from issue:

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

ggplot(mpg, aes(displ, hwy, colour = factor(cyl))) +
  geom_point() + 
  scale_colour_discrete(limits = c("4", "5", NA, "8"))

Created on 2024-04-18 with reprex v2.1.0

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 da60e8f into tidyverse:main Apr 29, 2024
7 of 12 checks passed
@teunbrand teunbrand deleted the discrete_na_limits branch April 29, 2024 08: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.

Wrong mapping provided to limits that include NA
2 participants