Color palettes



R Color Brewer palettes


Here are few examples of the many R Color Brewer palettes available and availables themes.

Available themes

Some examples :

# Libraries
library(ggplot2)

# 1 - Greys palette
ggplot(df, aes(x=cond, y=yval, fill=cond)) + 
  geom_bar(stat="identity") +
  scale_fill_brewer(palette="Greys") +
  theme(legend.position="none")

# 2 - PRGn palette
ggplot(df, aes(x=cond, y=yval, fill=cond)) + 
  geom_bar(stat="identity") +
  scale_fill_brewer(palette="PRGn") +
  theme(legend.position="none")

# 3 - Set1 palette
ggplot(df, aes(x=cond, y=yval, fill=cond)) + 
  geom_bar(stat="identity") +
  scale_fill_brewer(palette="Set1") +
  theme(legend.position="none")

# 4 - Spectral palette
ggplot(df, aes(x=cond, y=yval, fill=cond)) + 
  geom_bar(stat="identity") +
  scale_fill_brewer(palette="Spectral") +
  theme(legend.position="none")

Color blind friendly palettes


Here are two examples with color blind friendly palettes.

# 1 - The palette with grey:
cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")

ggplot(df, aes(x=cond, y=yval, fill=cond)) + 
  geom_bar(stat="identity") +
  scale_fill_manual(values=cbPalette) +
  theme(legend.position="none")

# 2 - The palette with black:
cbbPalette <- c("#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")

ggplot(df, aes(x=cond, y=yval, fill=cond)) + 
  geom_bar(stat="identity") +
  scale_fill_manual(values=cbbPalette) +
  theme(legend.position="none")



Contact

This document is a work by Emma Lafaurie (emma.lafaurie@inserm.fr) for the SBIM (Service de Biostatistique et Information Médicale) at Saint-Louis Hospital in Paris.
Based on the template of Yan Holtz.

Github SBIM