• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Data Viz with Python and R

Learn to Make Plots in Python and R

  • Home
  • Python Viz
  • Seaborn
  • Altair
  • R Viz
  • ggplot2
  • About
    • Privacy Policy
  • Show Search
Hide Search

Introduction to Color Palettes in R with RColorBrewer

datavizpyr · January 22, 2020 ·

RColorBrewer is a R package based on colorbrewer2.org that offers a variety of color palettes to use while making plots in R. Choosing which colors to use while making data visualization is not an easy task.

In this tutorial we will see the basics of color palettes available with RColorBrewer package. A Color palette is a set of colors that can be go together well while making a plot. For example, a color blind friendly color paletter would contain colors that will be visible to people with color blindness.

We can install RColorBrewer from CRAN

# install RColorBrewer
install.packages("RColorBrewer")

RColorBrewer uses colorbrewer2.org and offers three kinds of color palettes for most common use case scenario in making plots. The three kind of color palettes from RColorBrewer are Sequential color palettes, Diverging Color Palettes and Qualitative Color Palettes.

RColorBrewer also offers functionalities to quickly visualize the color palettes and to help choose the color palettes.

The Sequential palettes “are suited to ordered data that progress from low to high”. We can see the names and color palettes using

display.brewer.all(type="seq")
RColorBrewer Sequential Color Palettes
RColorBrewer Sequential Color Palettes

The Diverging palettes help emphasize the middle values and to the both side of the end values.

display.brewer.all(type="div")
RColorBrewer Diverging Palettes
RColorBrewer Diverging Color Palettes

And the Qualitative palettes help create the primary visual differences between classes/groups.

display.brewer.all(type="div")
RColorBrewer qualitative color palettes
RColorBrewer qualitative color palettes

We can also get all the information about the color palettes as a data from using brewer.pal.info. The dataframe contains maximum number of colors available for a color palette, its category whether it is diverging/sequential/quantitative and if the color palette is color blind friendly or not.

brewer.pal.info %>% 
      head()

##      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

We can use the data frame to slice and dice and view select color palettes. For example, we can visualize all color blind friendly color palettes using

brewer.pal.info %>% 
filter(colorblind==TRUE)

We can also view all the color blind friendly palettes using

display.brewer.all(colorblindFriendly=TRUE)
RColorBrewer color blind friendly palettes
RColorBrewer color blind friendly palettes

Related posts:

How to Make Heatmap with ggplot2?How To Make Simple Heatmaps with ggplot2 in R? Stacked Barplots Side By Side with ggplot2 in RHow to Make Horizontal Stacked Barplots with ggplot2 in R? Scatter Plot R: Fill color by variableHow To Color Scatter Plot by Variable in R with ggplot2? How to Make Barplots with Error bars in R?How To Make Barplots with Error bars in ggplot2?

Filed Under: Color Palettes RColorBrew, R Tagged With: R

Primary Sidebar

Tags

Altair barplot Boxplot boxplot python boxplot with jiitered text labels Bubble Plot Color Palette Countplot Density Plot Facet Plot gganimate ggplot2 ggplot2 Boxplot ggplot2 error ggplot boxplot ggridges ggtext element_markdown() Grouped Barplot R heatmap heatmaps Histogram Histograms Horizontal boxplot Python lollipop plot Maps Matplotlib Pandas patchwork pheatmap Pyhon Python R RColorBrewer reorder boxplot ggplot Ridgeline plot Scatter Plot Scatter Plot Altair Seaborn Seaborn Boxplot Stock Price Over Time Stripplot UpSetR Violinplot Violin Plot World Map ggplot2

Buy Me a Coffee

Copyright © 2025 · Daily Dish Pro on Genesis Framework · WordPress · Log in

Go to mobile version