Professional Documents
Culture Documents
Introduction
Safe colorsets
Session Info
References
colorBlindness Guide
Jianhong Ou
2021-04-16
Introduction
Color blindness is color vision deficiency, which means people with color blindness may be not aware of
differences among colors that are obvious to the people without it. This package is designed to provide a
collection of safe colors for plots such as heatmaps, pie chart, and try to find a solution for acceptable
figures for all the end users.
Safe colorsets
There are lots of packages already collected lots of safe colors. I list some of them, but not limited here.
munsell (https://CRAN.R-project.org/package=munsell)
dichromat (https://CRAN.R-project.org/package=dichromat)
colorblindr (https://github.com/clauswilke/colorblindr)
shades (https://CRAN.R-project.org/package=shades)
ggsci (https://CRAN.R-project.org/package=ggsci)
For this package, I will try to collect as much as possible safe color sets ready to use.
Francoise Vienot 1999(Viénot et al., 1999) (implemented in this package and package dichromat
(https://CRAN.R-project.org/package=dichromat) )
https://cran.r-project.org/web/packages/colorBlindness/vignettes/colorBlindness.html#How_to_use_this_package 1/9
16/12/2023 14:34 colorBlindness Guide
library(colorBlindness)
mat <- matrix(1:81, nrow = 9, ncol = 9)
library(ggplot2)
library(reshape2)
mat1 <- melt(t(mat[9:1, ]))
len <- length(Blue2DarkRed12Steps)-1
mat1$v2 <- cut(mat1$value,
breaks = seq(0,ceiling(81/len)*len,
length.out = len+1))
ht <- ggplot(mat1) +
geom_tile(aes(x=Var1, y=Var2, fill=v2)) +
scale_fill_manual(values=Blue2DarkRed12Steps) +
theme_bw()
# check the plot by CVD simulator
cvdPlot(ht)
https://cran.r-project.org/web/packages/colorBlindness/vignettes/colorBlindness.html#How_to_use_this_package 2/9
16/12/2023 14:34 colorBlindness Guide
https://cran.r-project.org/web/packages/colorBlindness/vignettes/colorBlindness.html#How_to_use_this_package 3/9
16/12/2023 14:34 colorBlindness Guide
If you have a fluorescence image and want to change the colors, you can read the figure and view the effect
of color changed figure. If it is acceptable, you can draw it into a file.
library(grid)
library(png)
path <- system.file("extdata", package = "colorBlindness")
img <- readPNG(file.path(path, "fluorescence.microscopy.images.png"))
g <- rasterGrob(img, interpolate=TRUE)
grid.draw(cvdPlot(g,
layout = c("origin", "deuteranope", "protanope",
"enhanced", "enhanced.deuteranope",
"enhanced.protanope")))
https://cran.r-project.org/web/packages/colorBlindness/vignettes/colorBlindness.html#How_to_use_this_package 4/9
16/12/2023 14:34 colorBlindness Guide
## quartz_off_screen
## 2
3. Proper figure colors that are distinguishable by people with colorblindness and for printed in black
and white.
setPDFopt function can provide you preset figure size for PDF outputs.
https://cran.r-project.org/web/packages/colorBlindness/vignettes/colorBlindness.html#How_to_use_this_package 5/9
16/12/2023 14:34 colorBlindness Guide
## $width
## [1] 7
##
## $height
## [1] 7
##
## $pointsize
## [1] 12
setPDFopt()
pdf.options()[c("width", "height", "pointsize")]
## $width
## 1col
## 3.54
##
## $height
## 1col
## 3.54
##
## $pointsize
## [1] 8
displayAvailablePalette(color="white")
https://cran.r-project.org/web/packages/colorBlindness/vignettes/colorBlindness.html#How_to_use_this_package 6/9
16/12/2023 14:34 colorBlindness Guide
The displayAllColors funciton can be used to show the effect for color vision deficiency. Here we dispaly
color collection from Bang Wong(Wong, 2011).
displayAllColors(safeColors, color="white")
https://cran.r-project.org/web/packages/colorBlindness/vignettes/colorBlindness.html#How_to_use_this_package 7/9
16/12/2023 14:34 colorBlindness Guide
Session Info
sessionInfo()
https://cran.r-project.org/web/packages/colorBlindness/vignettes/colorBlindness.html#How_to_use_this_package 8/9
16/12/2023 14:34 colorBlindness Guide
References
Brettel, H., Viénot, F., & Mollon, J. D. (1997). Computerized simulation of color appearance for dichromats.
JOSA A, 14(10), 2647–2655.
Brewer, C. A. (1997). Spectral schemes: Controversial color use on maps. Cartography and Geographic
Information Systems, 24(4), 203–220. https://doi.org/10.1559/152304097782439231
(https://doi.org/10.1559/152304097782439231)
Machado, G. M., Oliveira, M. M., & Fernandes, L. A. (2009). A physiologically-based model for simulation of
color vision deficiency. IEEE Transactions on Visualization and Computer Graphics, 15(6), 1291–1298.
Viénot, F., Brettel, H., & Mollon, J. D. (1999). Digital video colourmaps for checking the legibility of displays by
dichromats. Color Research & Application: Endorsed by Inter-Society Color Council, the Colour Group (Great
Britain), Canadian Society for Color, Color Science Association of Japan, Dutch Society for the Study of
Color, the Swedish Colour Centre Foundation, Colour Society of Australia, Centre Français de La Couleur,
24(4), 243–252.
https://cran.r-project.org/web/packages/colorBlindness/vignettes/colorBlindness.html#How_to_use_this_package 9/9