Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nowosad/colorblindcheck
Tools helping to decide if a color palette is colorblind friendly
https://github.com/nowosad/colorblindcheck
color-palette colors package r r-package rstats visualization
Last synced: 9 days ago
JSON representation
Tools helping to decide if a color palette is colorblind friendly
- Host: GitHub
- URL: https://github.com/nowosad/colorblindcheck
- Owner: Nowosad
- License: other
- Created: 2019-04-19T13:46:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-14T14:07:11.000Z (11 months ago)
- Last Synced: 2024-06-11T16:07:15.601Z (5 months ago)
- Topics: color-palette, colors, package, r, r-package, rstats, visualization
- Language: HTML
- Homepage: https://jakubnowosad.com/colorblindcheck/
- Size: 2.35 MB
- Stars: 27
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# colorblindcheck[![CRAN status](https://www.r-pkg.org/badges/version/colorblindcheck)](https://CRAN.R-project.org/package=colorblindcheck)
[![Codecov test coverage](https://codecov.io/gh/Nowosad/colorblindcheck/branch/master/graph/badge.svg)](https://app.codecov.io/gh/Nowosad/colorblindcheck?branch=master)
[![CRAN RStudio mirror downloads](https://cranlogs.r-pkg.org/badges/colorblindcheck)](https://cran.r-project.org/package=colorblindcheck)
[![R-CMD-check](https://github.com/Nowosad/colorblindcheck/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/Nowosad/colorblindcheck/actions/workflows/R-CMD-check.yaml)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](https://www.vis4.net/blog/automate-colorblind-checking) by Gregor Aisch.
## Installation
You can install the released version of **colorblindcheck** from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("colorblindcheck")
```You can install the development version of **colorblindcheck** from [GitHub](https://github.com/Nowosad/colorblindcheck) with:
```r
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**](https://cran.r-project.org/package=colorspace), [**RColorBrewer**](https://cran.r-project.org/package=RColorBrewer), [**rcartocolor**](https://cran.r-project.org/package=rcartocolor), etc.).```{r}
library(colorblindcheck)
rainbow_pal = rainbow(n = 7)
rainbow_pal
```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.
```{r}
palette_check(rainbow_pal, plot = TRUE)
```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 colorsAdditionally, 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.```{r}
# normal
palette_dist(rainbow_pal)
# protanopia
palette_dist(rainbow_pal, cvd = "pro")
```## References
- [Datawrapper now checks your colors, so you don’t have to](https://blog.datawrapper.de/colorblind-check/)
- [I wrote some code that automatically checks visualizations for non-colorblind safe colors. Here's how it works ](https://www.vis4.net/blog/automate-colorblind-checking)
- [Color Vision Deficiency Emulation](http://colorspace.r-forge.r-project.org/articles/color_vision_deficiency.html)
- [Delta E: The Color Difference](http://www.colorwiki.com/wiki/Delta_E:_The_Color_Difference)