-
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
values vector in scale_color_manual #4534
Comments
Issue #4511 also touches the extra colour key with predefined values. |
Could you update to the latest ggplot2 on CRAN (3.3.5) and let us know if you still have this problem? |
@clauswilke Adding |
* issue introduced in tidyverse#4471 * potential solution for tidyverse#4534 and tidyverse#4511 * add extra tests
* issue introduced in tidyverse#4471 * potential solution for tidyverse#4534 and tidyverse#4511 * add extra tests
It also has come to my attention that trying to do the opposite -displaying fewer legend keys- is also working in weird ways. In the code below, I would have expected both plots to do the same thing. Specifically, I would have expected the first plot to not have any grey points since the limits and values match up. library(ggplot2)
p <- ggplot(mpg, aes(displ, hwy, colour = drv)) +
geom_point(size = 2)
p +
scale_colour_manual(
values = c("dodgerblue", "tomato", "limegreen"),
limits = c("4", "f", "r"),
breaks = c("4", "r")
) p +
scale_colour_manual(
values = c("dodgerblue", "tomato", "limegreen"),
limits = c("4", "f", "r"),
breaks = function(x) c("4", "r")
) Created on 2021-09-15 by the reprex package (v2.0.1) |
Fixed by #4619 |
The behavior of
scale_color_manual(values = ...)
seems to have changed recently and broke many of my plots.Consider this example:
It now produces a figure with the blue color also in the legend.
I find that the following works (blue does not appear in the legend):
But this code looks unhappy. Is there a more robust way, in particular without extra temporary variables?
Is there somethin like
breaks = .df$fill
? This would be useful in many contexts.Sidenote. This would make more sense to me:
==
For lols, this works, too:
The text was updated successfully, but these errors were encountered: