ggplot2
ggplot2 copied to clipboard
Warn about ignored scales and guides
This PR aims to fix #3743 and guides indentified in https://github.com/tidyverse/ggplot2/issues/3196#issuecomment-2270818015.
Briefly, when using a scale or guide for an aesthetic that is not in use, you'll get a warning.
Implementation-wise, it wasn't too straightforward to allow guides and scales to assess their usage. A few remarks on this in the code.
An example:
devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2
ggplot(mpg, aes(displ, hwy, colour = drv)) +
geom_point() +
scale_fill_discrete() +
guides(shape = "bar")
#> Warning: Ignoring unknown guide: "shape".
#> Warning: Ignoring scale for unused aesthetics: "fill".

Created on 2024-08-07 with reprex v2.1.1