如何生成 30 种对色盲友好的不同颜色?
How to generate 30 distinct colors that are color-blind friendly?
我知道一些 R 包如 randomcolorR
和 pals
可以生成多种不同的颜色,但我不知道它们是否对色盲友好?
有没有更好的方法来获得约 30 种对色盲友好的不同颜色?或者有没有 table/web 我可以搜索色盲友好的颜色?以便我可以手动选择。
提前致谢。
viridis 包是一种选择,例如viridis::viridis(30)
会做到的。
注意 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.
无论如何:
Here 是 2 个(相似的)调色板,包含 8 种色盲友好颜色
# 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")
并且here的调色板包含 15 种适合色盲的颜色
pal <- c("#000000","#004949","#009292","#ff6db6","#ffb6db",
"#490092","#006ddb","#b66dff","#6db6ff","#b6dbff",
"#920000","#924900","#db6d00","#24ff24","#ffff6d")
我认为您可以使用 RColorBrewer
来做到这一点。色盲好像有27种颜色
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)
颜色:
[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"
我知道一些 R 包如 randomcolorR
和 pals
可以生成多种不同的颜色,但我不知道它们是否对色盲友好?
有没有更好的方法来获得约 30 种对色盲友好的不同颜色?或者有没有 table/web 我可以搜索色盲友好的颜色?以便我可以手动选择。
提前致谢。
viridis 包是一种选择,例如viridis::viridis(30)
会做到的。
注意 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.
无论如何:
Here 是 2 个(相似的)调色板,包含 8 种色盲友好颜色
# 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")
并且here的调色板包含 15 种适合色盲的颜色
pal <- c("#000000","#004949","#009292","#ff6db6","#ffb6db",
"#490092","#006ddb","#b66dff","#6db6ff","#b6dbff",
"#920000","#924900","#db6d00","#24ff24","#ffff6d")
我认为您可以使用 RColorBrewer
来做到这一点。色盲好像有27种颜色
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)
颜色:
[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"