How to generate 30 distinct colors that are color-blind friendly?

11.4k views Asked by At

I know some R packages like randomcolorR and pals can generate multiple distinct colors, but I do not know if they are color blind friendly?

Is there a better way to get ~30 distinct colors that are also color-blind friendly? Or is there any table/web I can search for colors that are color-blind friendly? So that I can pick manually.

Thank you in advance.

3

There are 3 answers

1
stevec On BEST ANSWER

Note that some sources recommend not using more than 8 colors in a colorblind-friendly palette

Also, it is recommended to use no more than 8 different colors.

In any case:

Here are 2 (similar) palettes of 8 colorblind friendly colors

enter image description here

# The palette with grey:
cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")

# The palette with black:
cbbPalette <- c("#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")

And here's a palette of 15 colorblind-friendly colors

enter image description here

pal <- c("#000000","#004949","#009292","#ff6db6","#ffb6db",
 "#490092","#006ddb","#b66dff","#6db6ff","#b6dbff",
 "#920000","#924900","#db6d00","#24ff24","#ffff6d")
1
jared_mamrot On

The viridis package is one option, e.g. viridis::viridis(30) will do it.

3
Agaz Wani On

I think you can use RColorBrewer to do that. It seems it has 27 colors for colorblind

library(RColorBrewer)
n <- 30
colrs <- brewer.pal.info[brewer.pal.info$colorblind == TRUE, ]
col_vec = unlist(mapply(brewer.pal, colrs$maxcolors, rownames(colrs)))
col <- sample(col_vec, n)
area <- rep(1,n)
pie(area, col = col)

enter image description here

colors:

[1] "#E5F5F9" "#1D91C0" "#67001F" "#F7FCFD" "#CB181D" "#78C679" "#F46D43" "#A6CEE3" "#FD8D3C" "#A6D854"
    [11] "#D4B9DA" "#6A51A3" "#7F0000" "#D9D9D9" "#FFF7BC" "#000000" "#F0F0F0" "#C7EAE5" "#003C30" "#F16913"
    [21] "#FFF7FB" "#8C6BB1" "#C7E9B4" "#762A83" "#FC9272" "#AE017E" "#F7F7F7" "#DF65B0" "#EF3B2C" "#74C476"