I would like to remove some legend entries in my ggplot
.
Previously, this was possible by defining the breaks
parameter in the relevant scale
, as explained here. However, that functionality seems to be broken with a recent update.
Example:
ggplot(mtcars) +
geom_col(aes(x = 1:nrow(mtcars), y = disp, fill = paste(cyl))) +
scale_fill_manual(values = c("grey50", "grey60", "grey70"),
breaks = c("4"))
While this code snippet only diplays one legend item, as intended, it does not allow to control the colours of the non-displayed elements.
With the breaks
attribute omitted: