MyNixOS website logo
Description

Check Color Palettes for Problems with Color Vision Deficiency.

Compare color palettes with simulations of color vision deficiencies - deuteranopia, protanopia, and tritanopia. It includes calculation of distances between colors, and creating summaries of differences between a color palette and simulations of color vision deficiencies. This work was inspired by the blog post at <http://www.vis4.net/blog/2018/02/automate-colorblind-checking/>.

colorblindcheck

CRANstatus Codecov testcoverage CRAN RStudio mirrordownloads R-CMD-check

Deciding if a color palette is a colorblind friendly is a hard task. This cannot be done in an entirely automatic fashion, as the decision needs to be confirmed by visual judgments. The goal of colorblindcheck is to provide tools to decide if the selected color palette is colorblind friendly, including:

  • palette_dist() - Calculation of the distances between the colors in the input palette and between the colors in simulations of the color vision deficiencies: deuteranopia, protanopia, and tritanopia.
  • palette_plot() - Plotting of the original input palette and simulations of color vision deficiencies: deuteranopia, protanopia, and tritanopia.
  • palette_check() - Creating summary statistics comparing the original input palette and simulations of color vision deficiencies: deuteranopia, protanopia, and tritanopia.

The work in this package was inspired by a blog post I wrote some code that automatically checks visualizations for non-colorblind safe colors. Here’s how it works by Gregor Aisch.

Installation

You can install the released version of colorblindcheck from CRAN with:

install.packages("colorblindcheck")

You can install the development version of colorblindcheck from GitHub with:

remotes::install_github("nowosad/colorblindcheck")

Example

The colorblindcheck accepts a vector of hexadecimal color descriptions as the input. It can be created using different existing R functions (e.g. rainbow()) or packages (e.g. colorspace, RColorBrewer, rcartocolor, etc.).

library(colorblindcheck)
rainbow_pal = rainbow(n = 7)
rainbow_pal
#> [1] "#FF0000" "#FFDB00" "#49FF00" "#00FF92" "#0092FF" "#4900FF" "#FF00DB"

The primary function in this package is palette_check(), which creates a summary comparison between the original input palette and simulations of color vision deficiencies - deuteranopia, protanopia, and tritanopia.

palette_check(rainbow_pal, plot = TRUE)
#>           name n tolerance ncp ndcp  min_dist mean_dist  max_dist
#> 1       normal 7  12.13226  21   21 12.132257  61.06471 107.63470
#> 2 deuteranopia 7  12.13226  21   19  2.572062  44.29065  85.87461
#> 3   protanopia 7  12.13226  21   17  3.647681  47.63882  83.28286
#> 4   tritanopia 7  12.13226  21   20  2.025647  47.41585  83.77189

The palette_check() function returns a data.frame with 4 observations and 8 variables:

  • name: original input color palette (normal), deuteranopia, protanopia, and tritanopia
  • n: number of colors
  • tolerance: minimal value of the acceptable difference between the colors to distinguish between them
  • ncp: number of color pairs
  • ndcp: number of differentiable color pairs (color pairs with distances above the tolerance value)
  • min_dist: minimal distance between colors
  • mean_dist: average distance between colors
  • max_dist: maximal distance between colors

Additionally, a plot comparing the original input palette and simulations of color vision deficiencies - deuteranopia, protanopia, and tritanopia can be shown. This help to decide if the selected color palette is colorblind friendly.

For example, the above output shows that the minimal distance between colors in the input palette is about 12; however, the minimum distance between colors simulation of tritanopia is only about 2. It can suggest that some colors in this palette would not be distinguishable by people with color vision deficiencies.

The palette_dist() function calculates distances between the colors in the input palette, as well as in a simulation of the selected color vision deficiency - deuteranopia, protanopia, and tritanopia. It allows finding which colors are the most or the least similar and to compare the behavior of color palettes for different color vision deficiencies. In the original rainbow_pal object, the closest colors were the third and the fourth one (a distance of about 12); however, the protanopia version has a minimal distance of 3 between the second and third color.

# normal
palette_dist(rainbow_pal)
#>      [,1]     [,2]     [,3]     [,4]     [,5]     [,6]      [,7]
#> [1,]   NA 52.96503 85.06611 84.19100 52.61836 51.46782  39.46279
#> [2,]   NA       NA 29.34232 34.74051 65.68745 92.04784  80.83188
#> [3,]   NA       NA       NA 12.13226 69.12782 81.23889 107.63470
#> [4,]   NA       NA       NA       NA 56.87222 74.19228 103.11485
#> [5,]   NA       NA       NA       NA       NA 35.47760  44.20031
#> [6,]   NA       NA       NA       NA       NA       NA  29.94683
#> [7,]   NA       NA       NA       NA       NA       NA        NA
# protanopia
palette_dist(rainbow_pal, cvd = "pro")
#>      [,1]     [,2]      [,3]     [,4]     [,5]     [,6]     [,7]
#> [1,]   NA 39.43191 42.508590 42.04093 58.64577 63.65418 55.96197
#> [2,]   NA       NA  3.647681 10.17970 63.89346 80.53512 69.20692
#> [3,]   NA       NA        NA 10.08224 65.80826 83.28286 71.54135
#> [4,]   NA       NA        NA       NA 58.30889 74.33303 64.46117
#> [5,]   NA       NA        NA       NA       NA 19.99978 12.31211
#> [6,]   NA       NA        NA       NA       NA       NA 10.57924
#> [7,]   NA       NA        NA       NA       NA       NA       NA

References

Metadata

Version

1.0.2

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows