Introduction to Color Palettes in R with RColorBrewer
RColorBrewer is an R Programming Language package library that offers a variety of color palettes to use while making different types of plots. Colors impact the way we visualize data. If we have to make a data standout or we want a color-blind person to visualize the data as well as a normal person we have to use the right color palette. RColorBrewer does exactly that by compiling the right colors in palettes for a variety of use cases.
Installation
To install the RColorBrewer package in R Language we can use a cran mirror using:
R
# install RColorBrewer install.packages ( "RColorBrewer" ) |
After running this, select the desired cran mirror from the list of available mirrors and the package will be installed.
Now for using RColorBrewer, we can use
library("RColorBrewer")
RColorBrewer provides the following three types of palettes suitable for most common use cases:
1. Sequential color palettes:
The Sequential color palettes have colors ordered in intensity and saturation. So, they are best for the visualization of data that is ordered and progresses from high to low. We can see all sequential color palettes using:
R
display.brewer.all (type= "seq" ) |
Output:

Sequential color Palettes
2. Diverging color palettes:
The Diverging color palettes have colors ordered from hot to neutral to cool. So, they are best for the visualization of data that has an emphasis on middle values and both sides of the end values. We can see all diverging color palettes using:
R
display.brewer.all (type= "div" ) |
Output:

Diverging Color Palette
3. Qualitative color palettes:
The Qualitative color palettes have colors that are visually contrasting and different. So, they help create the primary visual differences between different categories or groups of data. We can see all Qualitative color palettes using:
R
display.brewer.all (type= "qual" ) |
Output:

Qualitative color palettes
We can list all the colors with their key information using:
R
brewer.pal.info |
Output:
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
ColorBlindness filter
In the above information, there is also a column for colorblindness information. This column tells whether a colorblind person can see all the colors of the palette or not. So, we can use this information to get all the color palettes suitable for colorblind people. We can view all such palettes using:
R
display.brewer.all (colorblindFriendly= TRUE ) |
Output:

Colorblind friendly palette
Please Login to comment...