Setting Defaults for geoms and scales ggplot2

后端 未结 2 1497
野的像风
野的像风 2020-11-29 08:41

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

2条回答
  •  暖寄归人
    2020-11-29 09:14

    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))
    

提交回复
热议问题