You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the outgoing default aesthetic should be returned invisibly when the user runs update_geom_default. The syntax could look something like:
library(ggplot2)
# invisibly capture previous state of defaultsold_aes<- update_geom_defaults("Point", aes(colour="red"))
# old_aes should essentially be the output of GeomPoint$default_aes before the previous line was run# easily reset to previous state
update_geom_defaults("Point",old_aes)
Justification
update_geom_default and update_stat_default are useful for applying consistent styles across multiple plots. However, there is (to my knowledge) no easy to way to reset all of the geometries and stats to their original aesthetics. For themes we have reset_theme_settings which returns the current theme to the original theme_gray. What's nice about reset_theme_settings is that the user does not need to know what the actual default values of theme_gray are. I believe similar functionality should be available for the modifications to Geom default aesthetics.
Currently, the user would have do something like this to safely reset the default aesthetic:
And while that definitely works, it requires the user to learn about the Geoms, and the extra line of code feels like it introduces a degree of separation that's not necessary
Implementation
The current version of update_geom_default and update_stat_default (as of 04a5ef2, code available here) appear to mostly have this functionality built in. The functions already create variables called old <- g$default_aes which store the outgoing default values, and then the functions end with invisible() (so not returning anything). I believe, swapping those lines out with invisible(old) would implement this suggestion. I would be happy to submit a PR if the implementation is as such.
The text was updated successfully, but these errors were encountered:
Thanks Aaron for this suggestion. I agree with you that update_{geom/stat}_defaults() should return their previous value. This has been suggested before in #4993 (comment). The suggestion is also included in #5098. The PR currently awaits review.
Requested Feature
I think the outgoing default aesthetic should be returned invisibly when the user runs
update_geom_default
. The syntax could look something like:Justification
update_geom_default
andupdate_stat_default
are useful for applying consistent styles across multiple plots. However, there is (to my knowledge) no easy to way to reset all of the geometries and stats to their original aesthetics. For themes we havereset_theme_settings
which returns the current theme to the originaltheme_gray
. What's nice aboutreset_theme_settings
is that the user does not need to know what the actual default values oftheme_gray
are. I believe similar functionality should be available for the modifications to Geom default aesthetics.Currently, the user would have do something like this to safely reset the default aesthetic:
Created on 2023-12-28 with reprex v2.0.2
And while that definitely works, it requires the user to learn about the
Geom
s, and the extra line of code feels like it introduces a degree of separation that's not necessaryImplementation
The current version of
update_geom_default
andupdate_stat_default
(as of 04a5ef2, code available here) appear to mostly have this functionality built in. The functions already create variables calledold <- g$default_aes
which store the outgoing default values, and then the functions end withinvisible()
(so not returning anything). I believe, swapping those lines out withinvisible(old)
would implement this suggestion. I would be happy to submit a PR if the implementation is as such.The text was updated successfully, but these errors were encountered: