Learn R Programming

colorblindr

Simulate colorblindness in production-ready R figures. Written by Claire D. McWhite and Claus O. Wilke.

Try out simulations at http://hclwizard.org/cvdemulator/.

Installation

This package depends on the development versions of cowplot and colorspace. Please install those packages first:

remotes::install_github("wilkelab/cowplot")
install.packages("colorspace", repos = "http://R-Forge.R-project.org")

Then install colorblindr:

remotes::install_github("clauswilke/colorblindr")

Quick start

Make a figure:

library(ggplot2)
fig <- ggplot(iris, aes(Sepal.Length, fill = Species)) + geom_density(alpha = 0.7)
fig

Now look at it in various color-vision-deficiency simulations:

library(colorblindr)
cvd_grid(fig)

Then inspect it in the interactive app:

view_cvd(p) # starts the interactive app

To use a color scale that works somewhat better for people with color-vision deficiency, we recommend scale_color_OkabeIto and scale_fill_OkabeIto:

fig2 <- ggplot(iris, aes(Sepal.Length, fill = Species)) + 
  geom_density(alpha = 0.7) + scale_fill_OkabeIto()
fig2

That figure after color-vision-deficiency simulation:

cvd_grid(fig2)

Copy Link

Version

Version

0.1.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Claus O Wilke

Last Published

August 13th, 2020

Functions in colorblindr (0.1.0)

desaturate

Turn colors into their gray values
deutan

Convert colors using the deutan model of colorblindness
deutan_transform

Generate color transformation matrices using the deutan model of colorblindness
edit_colors

Edit colors in existing plot or grid object
palette_OkabeIto

Color palette proposed by Okabe and Ito
palette_plot

Visualize a color palette as swatches of colors, possibly with labels printed on top
tritan

Convert colors using the tritan model of colorblindness
tritan_transform

Generate color transformation matrices using the tritan model of colorblindness
protan

Convert colors using the protan model of colorblindness
protan_transform

Generate color transformation matrices using the protan model of colorblindness
view_cvd

Interactively view cvd simulations of a figure or plot
cvd

Color vision deficiency (cvd) conversion tables
cvd_grid

Create a grid of different color-deficiency simulations of a plot
scale_colour_OkabeIto

Okabe-Ito color scale
simulate_cvd

Simulate color vision deficiency given a cvd transform matrix
HCL_color_picker

Shiny app to pick colors in HCL space
gg_color_swatches

Generate a set of color swatches to be colored via ggplot2's scale_fill_* mechanism
gg_color_gradient

Generate a continuous color gradient to be colored via ggplot2's scale_fill_* mechanism