Setting ggplot2 default color scales

ggplot2 is a very nice R plotting library, however some people do not like the default color scales for plots. You can explicitly set the color scale for each one of your plots, but a better solution would be to simply change the defaults.

## Warning in rm(scale_colour_discrete): object 'scale_colour_discrete' not
## found
library(ggplot2)

#default colors
qplot(data=iris, Petal.Length, Petal.Width, color=Species, size=I(4))

#change default without arguments
scale_colour_discrete <- scale_colour_grey
last_plot()

#change default with arguments
scale_colour_discrete <- function(...) scale_color_brewer(palette="Set1")
last_plot()

Avatar
Jim Hester
Software Engineer

I’m a Senior Software Engineer at Netflix and R package developer.

Related