Closed
Description
Hello,
This might be related to #3372.
I need to combine several plots in a grid and make one shared legend. For this, I used to set manually the legend values and limits in the colour scale. But it doesn't work anymore
Here is a reprex:
ggplot(mpg, aes(class, hwy, col=class)) +
geom_boxplot() +
scale_color_manual(values=c("suv"="blue", "compact"="red", "pickup"="green", "foo"="orange", "bar"="pink"),
limits=c("suv", "compact", "pickup", "foo", "bar") )
The levels are added to the legend ("foo" and "bar") but the corresponding symbols are not shown.
I tried (man many other things) adding a blank geom but it didn't help (same output).
ggplot(mpg, aes(class, hwy, col=class)) +
geom_boxplot() +
geom_blank(data=~mutate(., class=fct_recode(class, "foo"="compact", "bar"="pickup"))) +
scale_color_manual(values=c("suv"="blue", "compact"="red", "pickup"="green", "foo"="orange", "bar"="pink"),
limits=c("suv", "compact", "pickup", "foo", "bar") )
This used to be with previous version of ggplot2 (3.4.1 on top of my head), but does not anymore with 3.5.1.
Thank you in advance for your guidance.
Metadata
Metadata
Assignees
Labels
No labels