11

I'd like to define a theme for ggplot2 so that the default colour of geom_bar() is not black.

How can I do this?

JerryWho
  • 3,060
  • 6
  • 27
  • 49

2 Answers2

9

you can't do it in a theme (sadly).

You want to change the default settings of a geom,

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

and you can also change a default scale, e.g.

  scale_colour_continuous <- function(...) 
         scale_colour_gradient(low = "blue", high = "red", na.value="grey50", ...)
baptiste
  • 75,767
  • 19
  • 198
  • 294
  • Thanks for the answer. As you mentioned that's not exactly what I was looking for but better than to specify the color in each geom_bar. – JerryWho Jun 17 '13 at 18:56
1

Theme controls apperance of non-data elements, so you need to work with scale functions. Try scale_fill_brewer, e.g.:

 scale_fill_brewer(palette = "Set1")

For details on this function see here.

topchef
  • 19,091
  • 9
  • 63
  • 102