Colorblind checks for qualitative palettes

R
color

Checking the color blind friendliness of a number of qualitative palettes.

Author
Affiliation

Monash University

Published

February 20, 2022

Function to generate plot for colorblind friendly check
library(ggplot2)
library(farver)
library(colorspace)
check_colorblindness <- function(colors, ncol = 3, label = TRUE) {
  ncolors <- length(colors)
  nrow <- ceiling(ncolors / ncol)
  cond <- c("Original", "Deutan", "Protan", "Tritan")
  ncond <- length(cond)
  
  df <- data.frame(color = c(colors, deutan(colors), protan(colors), tritan(colors)),
                   cond = rep(cond, each = ncolors),
                   x = rep(rep(1:ncol, length.out = ncolors), times = ncond),
                   y = rep(rep(1:nrow, each = ncol)[1:ncolors], times = ncond)) %>% 
    mutate(cond = factor(cond, levels = .env$cond))
  
  
  g <- ggplot(df, aes(x, y, fill = I(color))) +
    geom_tile(color = "black", size = 1.3) +
    theme_void() +
    coord_equal() +
    facet_wrap(~cond, ncol = 2) +
    scale_y_reverse()
  
  if(label) {
      g + geom_text(aes(label = color, color = I(label_col)), 
              data = function(data) data %>% 
                filter(cond == "Original") %>% 
                mutate(hcl = decode_colour(colors, to = "hcl"),
                       label_col = ifelse(hcl[, "l"] > 50, "black", "white")))
  } else {
    g
  } 
}
Name Source Colors # of colors Palette
High contrast Paul Tol #FFFFFF, #DDAA33, #BB5566, #004488, #000000 5
Pale Paul Tol #BBCCEE, #CCEEFF, #CCDDAA, #EEEEBB, #FFCCCC, #DDDDDD 6
Dark Paul Tol #222255, #225555, #225522, #666633, #663333, #555555 6
Bright Paul Tol #4477AA, #66CCEE, #228833, #CCBB44, #EE6677, #AA3377, #BBBBBB 7
Vibrant Paul Tol #0077BB, #33BBEE, #009988, #EE7733, #CC3311, #EE3377, #BBBBBB 7
Medium constrast Paul Tol #FFFFFF, #EECC66, #EE99AA, #6699CC, #997700, #994455, #004488, #000000 8
Okabe Ito Okabe Ito #E69F00, #56B4E9, #009E73, #F0E442, #0072B2, #D55E00, #CC79A7, #000000 8
Light Paul Tol #77AADD, #99DDFF, #44BB99, #BBCC33, #AAAA00, #EEDD88, #EE8866, #FFAABB, #DDDDDD 9
Muted Paul Tol #332288, #88CCEE, #44AA99, #117733, #999933, #DDCC77, #CC6677, #882255, #AA4499, #DDDDDD 10
Safe rcartocolor #88CCEE, #CC6677, #DDCC77, #117733, #332288, #AA4499, #44AA99, #999933, #882255, #661100, #6699CC, #888888 12
Monash primary Monash #006DAE, #000000, #FFFFFF, #5A5A5A, #969696, #E6E6E6 6
Monash secondary Monash #027EB6, #746FB2, #9651A0, #C8008F, #ee64a4, #EE0220, #D93F00, #795549, #6F7C4D, #008A25 10

R code for easy copying

### High contrast 
c("#FFFFFF", "#DDAA33", "#BB5566", "#004488", "#000000")

### Pale 
c("#BBCCEE", "#CCEEFF", "#CCDDAA", "#EEEEBB", "#FFCCCC", "#DDDDDD"
)

### Dark 
c("#222255", "#225555", "#225522", "#666633", "#663333", "#555555"
)

### Bright 
c("#4477AA", "#66CCEE", "#228833", "#CCBB44", "#EE6677", "#AA3377", 
"#BBBBBB")

### Vibrant 
c("#0077BB", "#33BBEE", "#009988", "#EE7733", "#CC3311", "#EE3377", 
"#BBBBBB")

### Medium constrast 
c("#FFFFFF", "#EECC66", "#EE99AA", "#6699CC", "#997700", "#994455", 
"#004488", "#000000")

### Okabe Ito 
c("#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", 
"#CC79A7", "#000000")

### Light 
c("#77AADD", "#99DDFF", "#44BB99", "#BBCC33", "#AAAA00", "#EEDD88", 
"#EE8866", "#FFAABB", "#DDDDDD")

### Muted 
c("#332288", "#88CCEE", "#44AA99", "#117733", "#999933", "#DDCC77", 
"#CC6677", "#882255", "#AA4499", "#DDDDDD")

### Safe 
c("#88CCEE", "#CC6677", "#DDCC77", "#117733", "#332288", "#AA4499", 
"#44AA99", "#999933", "#882255", "#661100", "#6699CC", "#888888"
)

### Monash primary 
c(blue = "#006DAE", black = "#000000", white = "#FFFFFF", gray80 = "#5A5A5A", 
gray50 = "#969696", gray10 = "#E6E6E6")

### Monash secondary 
c(blue = "#027EB6", purple = "#746FB2", fuchsia = "#9651A0", 
ruby = "#C8008F", pink = "#ee64a4", red = "#EE0220", orange = "#D93F00", 
umber = "#795549", olive = "#6F7C4D", green = "#008A25")

Closer look

High contrast palette: #FFFFFF, #DDAA33, #BB5566, #004488, #000000.

Pale palette: #BBCCEE, #CCEEFF, #CCDDAA, #EEEEBB, #FFCCCC, #DDDDDD.

Dark palette: #222255, #225555, #225522, #666633, #663333, #555555.

Bright palette: #4477AA, #66CCEE, #228833, #CCBB44, #EE6677, #AA3377, #BBBBBB.

Vibrant palette: #0077BB, #33BBEE, #009988, #EE7733, #CC3311, #EE3377, #BBBBBB.

Medium constrast palette: #FFFFFF, #EECC66, #EE99AA, #6699CC, #997700, #994455, #004488, #000000.

Okabe Ito palette: #E69F00, #56B4E9, #009E73, #F0E442, #0072B2, #D55E00, #CC79A7, #000000.

Light palette: #77AADD, #99DDFF, #44BB99, #BBCC33, #AAAA00, #EEDD88, #EE8866, #FFAABB, #DDDDDD.

Muted palette: #332288, #88CCEE, #44AA99, #117733, #999933, #DDCC77, #CC6677, #882255, #AA4499, #DDDDDD.

Safe palette: #88CCEE, #CC6677, #DDCC77, #117733, #332288, #AA4499, #44AA99, #999933, #882255, #661100, #6699CC, #888888.

Monash primary palette: #006DAE, #000000, #FFFFFF, #5A5A5A, #969696, #E6E6E6.

Monash secondary palette: #027EB6, #746FB2, #9651A0, #C8008F, #ee64a4, #EE0220, #D93F00, #795549, #6F7C4D, #008A25.