Theming for ggplot2 makes it quite easy to relegate the need for multiple or repetitive + opt()...
lines. However, I would like to know if there is a way to def
I can't think of anything useful for the geom
s, but for the scales
, one option would be to use the fact that components of ggplot
s are all simply R objects that can be saved, stored and reassigned like any other.
So you could perhaps create your own collection of "default" versions of many scales, like:
sfmDefault <- scale_fill_manual(...)
scmDefault <- scale_colour_manual(...)
etc. with your desired default values. Put them in your .RProfile or wherever and use them as needed.
There is another method for this now. You can essentially overwrite any aesthetics scale, for example:
scale_colour_discrete <- function(...) scale_colour_brewer(..., palette="Set2")
scale_fill_discrete <- function(...) scale_fill_brewer(... , palette="Set2")
Now, your aesthetics will be coloured or filled following that behaviour.'
As per: https://groups.google.com/forum/?fromgroups=#!topic/ggplot2/w0Tl0T_U9dI
With respect to defaults to geoms, you can use update_geom_defaults
, for example:
update_geom_defaults("line", list(size = 2))