-
Notifications
You must be signed in to change notification settings - Fork 2.1k
scale_fill_discrete makes fills with grey when using a named vector #4197
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
Comments
If given a named vector, ggplot2 will match the named colors to the limits of the scale. So in your example, the following palette would work: pal <- c("setosa" = "#F0A0FF", "versicolor" = "#0075DC", "virginica" = "#993F00") I think this is the intended behavior and you'll have to unname or rename the palettes you want to use, or else create a custom scale as in #4087 (and using the dev version of the scales package). |
isn't that what In any case, I think it would be useful to include something like " If this is a named vector, then the values will be matched based on the names instead. Data values that don't match will be given na.value."(which is from the |
Sounds good to me. Would you mind creating a pull request for this? |
I made a pull request (#4243) |
Hi,
I'm having a problem with
scale_fill_discrete
, where if I provide a named vector of colors as input, the colors are filled as grey. However, If I use an unnamed vector for the same colors, the plot works fineThis does not work
This does work
A bit of an edge case, but the
pals
package which I use a lot for my color palettes adds names to their discrete palettes.Any idea for a solution
Session info
The text was updated successfully, but these errors were encountered: