How to Stimulate Colorblindness Vision in R Figures

How to Stimulate Colorblindness Vision in R Figures

This article describes how to simulate colorblindness vision in production-ready R figures using the colorblinr package. We’ll also present some colorblind-friendly palette.

In some populations, up to 10% of men have color vision deficiencies (cvd).

The R package colorblindr can be used to simulate colorblindness in R. At the time that we write this document (2018-11-20), this package depends on the development versions of cowplot and colorspace.


Install colorblindr and dependencies

This section shows how to install colorblindr package and dependencies.

  1. Install devtools, which makes it easy to install the developmental version of the other packages
if(require(devtools)) install.packages("devtools")
  1. Install cowplot
  1. Install colorspace
# for windows use this
install.packages("colorspace", repos = "")

# Or for MAC OS X /Linux, use this: 
URL <- paste0("",
  1. Install colorblindr

Load required packages


Key R functions

Key functions in the colorblindr R package:

  • cvd_grid(): Create a grid of different color-vision-deficiency simulations of a plot.
  • edit_colors(): Edit colors in existing plot. Can modify colors in existing ggplot2 plots, grid objects, or R base plots provided as recorded plots.
  • scale_colour_OkabeIto() or scale_color_OkabeIto() and scale_fill_OkabeIto(): This is a color-blind friendly, qualitative scale with eight different colors.

Create a basic ggplot

p <- ggplot(iris, aes(Species, Sepal.Length)) +
  geom_boxplot(aes(fill = Species)) +
  theme_minimal() + 
  theme(legend.position = "none")

Color-vision-deficiency simulations

The function cvd_grid() can be used to quickly show the most severe forms of each color vision deficiency.


It’s also possible to edit a plot as follow:

# Use deutan, protan or tritan functions [in colorspace]
p2 <- edit_colors(p, deutan, sev = 0.7)
cowplot::plot_grid(p, p2)

Colorblind-friendly palettes

The colorblindr package comes with a color scale that works better for people with color-vision deficiency. You can use it to modify a ggplot color.

Key functions:

  • scale_colour_OkabeIto() or scale_color_OkabeIto()
  • scale_fill_OkabeIto()

For example, type this:

# Figure before cvd simulation
p3 <- p + scale_fill_OkabeIto()

Figure after color-vision-deficiency simulation:


New workflow for figure and image design

  1. Make figures or images
  2. Check colors using cvd_grid()
  3. Iterate color choices until colors are distinguishable in all conditions

Read more at: Color Universal Design (CUD) - How to make figures and presentations that are friendly to Colorblind people


This article introduces how to simulate colorblindness in production-ready figures using the R package colorblindr.

Version: Français

Comment ( 1 )

  • Eric

    I believe you mean simulate, not stimulate.

Give a comment

Want to post an issue with R? If yes, please make sure you have read this: How to Include Reproducible R Script Examples in Datanovia Comments