RNotes


ColorBrewer Palettes

library(RColorBrewer)

Sequential palettes

Sequential palettes are suited to ordered data that progress from low to high. Lightness steps dominate the look of these schemes, with light colors for low data values to dark colors for high data values.

All the sequential palettes are available in variations from 3 different values up to 9 different values.

par(mar=c(1,5,1,1))
display.brewer.all(type="seq")

brewer.pal.info[brewer.pal.info$category == "seq",]
##         maxcolors category colorblind
## Blues           9      seq       TRUE
## BuGn            9      seq       TRUE
## BuPu            9      seq       TRUE
## GnBu            9      seq       TRUE
## Greens          9      seq       TRUE
## Greys           9      seq       TRUE
## Oranges         9      seq       TRUE
## OrRd            9      seq       TRUE
## PuBu            9      seq       TRUE
## PuBuGn          9      seq       TRUE
## PuRd            9      seq       TRUE
## Purples         9      seq       TRUE
## RdPu            9      seq       TRUE
## Reds            9      seq       TRUE
## YlGn            9      seq       TRUE
## YlGnBu          9      seq       TRUE
## YlOrBr          9      seq       TRUE
## YlOrRd          9      seq       TRUE
brewer.pal.info["Blues",]
##       maxcolors category colorblind
## Blues         9      seq       TRUE
brewer.pal.info["Blues",]$maxcolors
## [1] 9
par(mar=c(1,1,1,1))
N <- 7
mypalette <- brewer.pal(N,"Blues")
image(1:7,1,as.matrix(1:N),col=mypalette,xlab="Blues (sequential)",
       ylab="",xaxt="n",yaxt="n",bty="n")

par(mar=c(1,1,1,1))
display.brewer.pal(N,"Blues")

Diverging Palettes

Diverging palettes put equal emphasis on mid-range critical values and extremes at both ends of the data range. The critical class or break in the middle of the legend is emphasized with light colors and low and high extremes are emphasized with dark colors that have contrasting hues.

All the diverging palettes are available in variations from 3 different values up to 11 different values.

par(mar=c(1,5,1,1))
display.brewer.all(type="div")

brewer.pal.info[brewer.pal.info$category == "div",]
##          maxcolors category colorblind
## BrBG            11      div       TRUE
## PiYG            11      div       TRUE
## PRGn            11      div       TRUE
## PuOr            11      div       TRUE
## RdBu            11      div       TRUE
## RdGy            11      div      FALSE
## RdYlBu          11      div       TRUE
## RdYlGn          11      div      FALSE
## Spectral        11      div      FALSE
display.brewer.all(n=5,type="div",exact.n=TRUE)

par(mar=c(1,1,1,1))
display.brewer.pal(7,"BrBG")

Qualitative Palettes

Qualitative palettes do not imply magnitude differences between legend classes, and hues are used to create the primary visual differences between classes. Qualitative schemes are best suited to representing nominal or categorical data.

For qualitative palettes, the lowest number of distinct values available always is 3, but the largest number is different for different palettes.

par(mar=c(1,5,1,1))
display.brewer.all(type="qual") 

brewer.pal.info[brewer.pal.info$category == "qual",]
##         maxcolors category colorblind
## Accent          8     qual      FALSE
## Dark2           8     qual       TRUE
## Paired         12     qual       TRUE
## Pastel1         9     qual      FALSE
## Pastel2         8     qual      FALSE
## Set1            9     qual      FALSE
## Set2            8     qual       TRUE
## Set3           12     qual      FALSE
par(mar=c(1,1,1,1))
display.brewer.pal(7,"Accent")

Color-Blind Friendly Palettes

par(mar=c(1,5,1,1))
display.brewer.all(colorblindFriendly=TRUE)

brewer.pal.info[brewer.pal.info$colorblind,]
##         maxcolors category colorblind
## BrBG           11      div       TRUE
## PiYG           11      div       TRUE
## PRGn           11      div       TRUE
## PuOr           11      div       TRUE
## RdBu           11      div       TRUE
## RdYlBu         11      div       TRUE
## Dark2           8     qual       TRUE
## Paired         12     qual       TRUE
## Set2            8     qual       TRUE
## Blues           9      seq       TRUE
## BuGn            9      seq       TRUE
## BuPu            9      seq       TRUE
## GnBu            9      seq       TRUE
## Greens          9      seq       TRUE
## Greys           9      seq       TRUE
## Oranges         9      seq       TRUE
## OrRd            9      seq       TRUE
## PuBu            9      seq       TRUE
## PuBuGn          9      seq       TRUE
## PuRd            9      seq       TRUE
## Purples         9      seq       TRUE
## RdPu            9      seq       TRUE
## Reds            9      seq       TRUE
## YlGn            9      seq       TRUE
## YlGnBu          9      seq       TRUE
## YlOrBr          9      seq       TRUE
## YlOrRd          9      seq       TRUE

All palettes simultanoeusly

par(mar=c(1,5,1,1))
display.brewer.all(n=10, exact.n=FALSE)

display.brewer.all(n=10)

display.brewer.all()

brewer.pal.info
##          maxcolors category colorblind
## BrBG            11      div       TRUE
## PiYG            11      div       TRUE
## PRGn            11      div       TRUE
## PuOr            11      div       TRUE
## RdBu            11      div       TRUE
## RdGy            11      div      FALSE
## RdYlBu          11      div       TRUE
## RdYlGn          11      div      FALSE
## Spectral        11      div      FALSE
## Accent           8     qual      FALSE
## Dark2            8     qual       TRUE
## Paired          12     qual       TRUE
## Pastel1          9     qual      FALSE
## Pastel2          8     qual      FALSE
## Set1             9     qual      FALSE
## Set2             8     qual       TRUE
## Set3            12     qual      FALSE
## Blues            9      seq       TRUE
## BuGn             9      seq       TRUE
## BuPu             9      seq       TRUE
## GnBu             9      seq       TRUE
## Greens           9      seq       TRUE
## Greys            9      seq       TRUE
## Oranges          9      seq       TRUE
## OrRd             9      seq       TRUE
## PuBu             9      seq       TRUE
## PuBuGn           9      seq       TRUE
## PuRd             9      seq       TRUE
## Purples          9      seq       TRUE
## RdPu             9      seq       TRUE
## Reds             9      seq       TRUE
## YlGn             9      seq       TRUE
## YlGnBu           9      seq       TRUE
## YlOrBr           9      seq       TRUE
## YlOrRd           9      seq       TRUE

ColorBrewer Info

ColorBrewer is Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State University. All rights reserved.

The ColorBrewer palettes have been included in this R package with permission of the copyright holder.

View the ColorBrewer web site.


packageVersion("RColorBrewer")
## [1] '1.1.2'

efg
2015-01-18 1920