Skip to content

More accurate check for palette names #4093

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 1 commit into from
Jun 26, 2020
Merged

Conversation

karawoo
Copy link
Member

@karawoo karawoo commented Jun 26, 2020

Closes #4087, specifically the issue where a named palette that didn't match the limits would still get used if too many colors were requested. We now use a more accurate check for whether the palette has names, so if the colors don't match the limits it won't be used. This is the conventional behavior, though as discussed on the issue it can be confusing. This PR makes the behavior consistent, but we might want to separately revisit whether to change the behavior of scales::manual_pal().

Some of the names can be NA if more colors are requested than are present in the
palette. is_named() would return FALSE in this case, so it's changed here to
`!is_null(names(pal))`.
@karawoo karawoo requested a review from yutannihilation June 26, 2020 00:28
Copy link
Member

@yutannihilation yutannihilation left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@karawoo karawoo merged commit b4e3aea into tidyverse:master Jun 26, 2020
@karawoo karawoo deleted the names-check branch June 26, 2020 04:31
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.

Nothing plotted with manual_scale when a named vector is used as the input.
2 participants