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

4

8

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.

Relucent answered 25/11, 2020 at 22:12 Comment(8)
My understanding is that all colors are colorblind friendly; the consideration is whether sets of colors can be distinguished by colorblind viewers. I would find out what the rules are for those relations — something like avoiding color pairs whose only difference lies in red or green — and do the work in a perceptual colorspace such as YCbCr instead of RGB.Baroja
Maybe of any help davidmathlogic.com/colorblind/…Cynar
The package RColorBrewer has color-blind friendly palettes.Nephro
There are 8 colors here (but obviously that's insufficient, but at least a start)Ordinand
30 distinct colors is a lot, even for people with "normal" color vision. Most of the designed color-blind friendly palettes limit the number of colors in a set to still consider it color-blind friendly.Ingulf
Adjacent to your question: To check how a data viz would appear to a colorblind person, you can use simulators such as color-blindness.com/coblis-color-blindness-simulatorContuse
@Contuse that's extrmely interesting. Are all 8 of the views corresponding to different variants of colorblindness? (e.g. Red-Weak/Protanomaly, etc etc) ?Ordinand
@Ordinand Yes, they are all different kinds of color blindness. The most common one is Green-Weak/Deuteranomaly.Contuse
O
6

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")
Ordinand answered 25/11, 2020 at 22:33 Comment(1)
I think 30 is too many. I will choose your answer, since your colors seem most distinguishable.Relucent
M
2

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

Manzo answered 25/11, 2020 at 22:29 Comment(1)
I believe this is not categorical color?Relucent
M
0

As another voice from the peanut gallery, I cannot differentiate several of the colors in that supposed color-blind safe palette. I also think expecting anyone to try and pick out the difference, esp. in line plots or small dot plots, or any other time there either low color to background ratio, or a lot of adjacent/overlapping data points, in larger palettes is pushing it.

I would really encourage use of different data point markers (finally, a use for emojis), different patterns of lines, etc. to accentuate esp. key points.

[#26, #12, #8]; [#14, #7, #29, #15]; [#1, #4, #6, #11, #20]; [#5, #23]; [#3, #30, #17, #18, #22, #24].

Another tip: Never use a combination of text and backgrounds (e.g. slides--what is wrong w/ black or white???) of dark red, dark green, and black. Same for blue/purple combinations, which are less common. Also, if you slides are just an outline of your talk, just hand out an outline and skip the slides. Check out Visual Display of Quantitative Information Second to using color-blind safe palettes, its probably the best thing you can do for your data displays/talks.
I know, it is an over-priced, old, on-paper only book. I think there is a three book set, the other two books are also very good. Anyone in data science, UX in a technical field, or into design really should be familiar.

Meit answered 13/5 at 14:42 Comment(0)
C
-1

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"
Cynar answered 25/11, 2020 at 22:47 Comment(3)
This is clever but wrong (I think).You can't get a bigger "colorblind-friendly" palette by squashing together two colorblind-friendly palettes!Truda
@BenBolker Maybe you are right. Can you please elaborate?Cynar
#8 #12 and #26 are identical to me (colorblind) 1, 4, and 6 are very close too same for 3, 18 19. I stop here as this will be different for other people suffering of color-blindness. I also do not believe more than 8 colors can be used in that context. @Ordinand 's second set is fine although do not ask me to name these colors. This being another concept that non-color-blind have difficulties understanding. We often see the colors but cannot -name- them. Hope this shed some light!Mariejeanne

© 2022 - 2024 — McMap. All rights reserved.