tidyverse / ggplot2

An implementation of the Grammar of Graphics in R
https://ggplot2.tidyverse.org
Other
6.48k stars 2.02k forks source link

Could a function to reset all geom defaults back to the initial defaults be provided? #5975

Closed davidhodge931 closed 1 month ago

davidhodge931 commented 3 months ago

Thanks for the continual ggplot2 updates!

I was wondering if there could be a function to reset all geom defaults back to the initial defaults? Otherwise, you have to know what the defaults are, or restart once you update something.

Something simple like below would be super helpful.

reset_geom_defaults <- function() {
  ggplot2::update_geom_defaults("area", NULL)
  ggplot2::update_geom_defaults("bar", NULL)
  ggplot2::update_geom_defaults("boxplot", NULL)
  ggplot2::update_geom_defaults("col", NULL)
  ... # etc with all geom's there
}

Maybe this could be something for Tidy Dev Day, as hopefully pretty simple??

An idea (maybe for the future) is that it could also have an argument that would allow users to specify only certain geoms to reset

teunbrand commented 3 months ago

I can see value in a grand reset of the default aesthetics. I feel that the geoms shouldn't be hardcoded like in the example you give, which makes it somewhat more complicated.

you have to know what the defaults are

This isn't strictly true, but you have to know which geoms one should reset.

However, I don't think the update_geom_defaults() will be the 'preferred way' of interacting with defaults after #5833 gets merged.

davidhodge931 commented 3 months ago

Thanks, @teunbrand

Do you forsee that update_geom_defaults will be continued to be supported?

I find it super useful

teunbrand commented 3 months ago

I see no reason for superseding it, so yes I think it'll be around a while.