-
Notifications
You must be signed in to change notification settings - Fork 2k
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
scale_colour_manual() silently ignores drop = TRUE #4723
Comments
Looks like this may be resolved by #4619 — I'll be patient and use Will |
As far as I can tell, it does what you expect in the development version of ggplot2. # devtools::install_github("tidyverse/ggplot2")
library(tidyverse)
my_global_palette <- c("2" = "black", "4" = "orange", "6" = "blue", "8" = "darkgreen")
df <- mutate(mtcars, cyl = factor(cyl, levels = as.character(c(2,4,6,8))))
p <- ggplot(df, aes(mpg, wt, color = cyl)) + geom_point()
p + scale_colour_manual(values = my_global_palette, drop = TRUE) p + scale_colour_manual(values = my_global_palette, drop = FALSE) Created on 2022-02-03 by the reprex package (v2.0.1) |
Closing as this is already resolved by #4619. (If I'm missing something, please let me know) |
This might be expected behavior but it seems to conflict with the documentation:
Reprex
As Expected
Unexpected
Description
?scale_manual
says:scale_colour_manual(..., drop = TRUE)
silently accepts thedrop
argument, but in the last example above, the factor level "2" is still shown in the legend.Maybe the intent is for
values
to take precedence over thedrop
argument, but (a) this is unclear from the documentation, and (b) I think a case could be made against it. A user may wish to define and reuse a default palette without all elements of that palette appearing every time. (Maybe that's achievable in some other way?)The text was updated successfully, but these errors were encountered: