Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Plot Color Combinations that Are Colorblind Accessible

How do I choose 4-8 colors in base R for plots that colorblind people will be able to see?

Below is the base R color pallet. Looking for a solution in BASE R without the use of packages.

Base R Color Palette Guide: http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf

Color Palettes for Color Blindness: http://mkweb.bcgsc.ca/colorblind/

Specifically how do I manually create accessible colors in BASE R?

e.g. "vermilion", "bluish green", and "reddish purple" as described in the paper figure below.

enter image description here

like image 853
Mark Avatar asked Jul 22 '19 20:07

Mark


People also ask

What color combos are good for colorblind?

Use a colorblind-friendly palette when appropriate For example, blue/orange is a common colorblind-friendly palette. Blue/red or blue/brown would also work. For the most common conditions of CVD, all of these work well, since blue would generally look blue to someone with CVD.

How do you make a chart color blind friendly?

The first rule of making a palette for colorblind – avoid combining red and green. So if you're aiming to create a color blind-friendly palette try to use only two basic hues: blue and red (orange and yellow will also fit). The other colors should be made out of these two hues.

What colors do colorblind not see?

Avoid bad color combos That being said, here's a few color combinations to avoid because they're a potential nightmare to color blind users: Green & Red. Green & Brown. Blue & Purple.


Video Answer


3 Answers

These are the hex codes for those colors in the image you posted

colorBlindBlack8  <- c("#000000", "#E69F00", "#56B4E9", "#009E73", 
                       "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
pie(rep(1, 8), col = colorBlindBlack8)

colorBlindGrey8   <- c("#999999", "#E69F00", "#56B4E9", "#009E73", 
                       "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
scales::show_col(colorBlindGrey8)

For more than 8 colors, rcartocolor has the Safe palette with 12 colors

safe_colorblind_palette <- c("#88CCEE", "#CC6677", "#DDCC77", "#117733", "#332288", "#AA4499", 
                             "#44AA99", "#999933", "#882255", "#661100", "#6699CC", "#888888")
scales::show_col(safe_colorblind_palette)

If you need sequential or diverging colormaps, check these palettes out

library(rcartocolor)
display_carto_all(colorblind_friendly = TRUE)

Created on 2019-07-22 by the reprex package (v0.3.0)

like image 124
Tung Avatar answered Oct 13 '22 20:10

Tung


Okabe-Ito palette

The palette shown in the question is also known as the Okabe-Ito palette as suggested by Okabe & Ito (2008). Since version 4.0.0, base R provides a new palette.colors() where this palette is actually the default:

palette.colors(palette = "Okabe-Ito")
##         black        orange       skyblue   bluishgreen        yellow 
##     "#000000"     "#E69F00"     "#56B4E9"     "#009E73"     "#F0E442" 
##          blue    vermillion reddishpurple          gray 
##     "#0072B2"     "#D55E00"     "#CC79A7"     "#999999" 

Qualitative palettes in base R

Along with this palette, various other qualitative palettes are easily available in base R. Specifically, the new default palette (called "R4") has also been designed to be rather robust under color vision deficiencies. See this blog post for further details:

  • Zeileis, Murrell, Maechler, Sarkar (2019). "A New palette() for R." The R Blog.

overview of various palettes in the palette.colors function

Sequential and diverging palettes in base R

In addition to the qualitative palettes above, base R also has a new function hcl.colors() since version 3.6.0 that makes many sequential and diverging palettes available that are also robust under color vision deficiencies. It provides approximations (derived using the hue-chroma-luminance color model) to many palettes from ColorBrewer.org, viridis, CARTO colors, Crameri's scientific colors etc. The default is the popular viridis palette. The following blog post provides more details and the paper about the colorspace package explains more related/underlying work.

  • Zeileis, Murrell (2019). "HCL-Based Color Palettes in grDevices." The R Blog.
  • Zeileis, Fisher, Hornik, Ihaka, McWhite, Murrell, Stauffer, Wilke (2020). "colorspace: A Toolbox for Manipulating and Assessing Colors and Palettes." Journal of Statistical Software.

overview of sequential palettes in the hcl.colors function

overview of diverging palettes in the hcl.colors function

like image 35
Achim Zeileis Avatar answered Oct 13 '22 19:10

Achim Zeileis


The color scales in the viridis package are all color blind accessible. https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html#the-color-scales

If you need to use colors by name like in the pdf you linked to, match colors from the viridis palettes to the named list of colors. For 4-8, this is pretty easy to do visually.

like image 2
tim Avatar answered Oct 13 '22 19:10

tim