Skip to content
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

Reset original defaults with update_geom_defaults() #4993

Closed
bwiernik opened this issue Sep 21, 2022 · 5 comments · Fixed by #5781
Closed

Reset original defaults with update_geom_defaults() #4993

bwiernik opened this issue Sep 21, 2022 · 5 comments · Fixed by #5781
Labels
feature a feature request or enhancement

Comments

@bwiernik
Copy link
Contributor

bwiernik commented Sep 21, 2022

Sometimes, as I'm interactively building a plot, I change geom default aesthetics with update_geom_defaults(), then change my mind and want to put them back. Currently, I don't see a way to do that other than by knowing what the original defaults were or restarting my R session.

It would be really helpful to be able to do something like this to reset the size default to 1.5:

update_geom_defaults("geom", list(size = NULL))

And/or like this to reset all aesthetics to their original defaults:

update_geom_defaults("geom", NULL)
@clauswilke
Copy link
Member

As far as I can tell, we just overwrite the settings for the geom, so afterwards we don't have them anymore either.

update_geom_defaults <- function(geom, new) {
g <- check_subclass(geom, "Geom", env = parent.frame())
old <- g$default_aes
g$default_aes <- defaults(rename_aes(new), old)
invisible()
}

At some point there was talk about saving the geom defaults in the theme, and that would be a great solution for this problem, but I think there hasn't been much development on the PR for a long time now.

@hadley
Copy link
Member

hadley commented Sep 26, 2022

One small improvement here would be for update_geom_defaults() to invisibly return the previous values. That's our standard convention for functions that modify global state.

@davidhodge931
Copy link

Related to this, could there be a way to easily reset all geom defaults back to originals?

Maybe when the geom argument is NULL?
update_geom_updates(geom = NULL, update = NULL)

Or maybe a new function like reset_geom_updates()?

@teunbrand
Copy link
Collaborator

Reviving this issue for after 3.5.1

@teunbrand
Copy link
Collaborator

Considering this closed (again) after #5846.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants