Ggplot2: how to set the default color geom_bar () in a theme

I would like to define a theme for ggplot2 so that the default geom_bar () color is not black.

How can i do this?

+6
source share
2 answers

you cannot do this in the subject (unfortunately).

You want to change the default geometry settings,

update_geom_defaults("bar", list(fill = "red")) 

and you can also change the default scale, for example.

  scale_colour_continuous <- function(...) scale_colour_gradient(low = "blue", high = "red", na.value="grey50", ...) 
+6
source

The theme controls non-data elements, so you need to work with scale functions. Try scale_fill_brewer , for example:

  scale_fill_brewer(palette = "Set1") 

See here for more on this feature.

0
source

Source: https://habr.com/ru/post/947480/


All Articles