An open API service indexing awesome lists of open source software.

https://github.com/clauswilke/colorblindr

An R package to simulate colorblindness on R figures.
https://github.com/clauswilke/colorblindr

Last synced: about 4 hours ago
JSON representation

An R package to simulate colorblindness on R figures.

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```

# colorblindr

[![Build Status](https://travis-ci.org/clauswilke/colorblindr.svg?branch=master)](https://travis-ci.org/clauswilke/colorblindr)
[![Coverage Status](https://img.shields.io/codecov/c/github/clauswilke/colorblindr/master.svg)](https://codecov.io/github/clauswilke/colorblindr?branch=master)

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

# Installation

This package depends on the development versions of **cowplot** and **colorspace**. Please install those packages first:
```
devtools::install_github("wilkelab/cowplot")
install.packages("colorspace", repos = "http://R-Forge.R-project.org")
```

Then install **colorblindr**:
```
devtools::install_github("clauswilke/colorblindr")
```

# Quick start

Make a figure:
```{r iris-figure, fig.width = 5, fig.asp = .69}
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:
```{r iris-cvd-grid, fig.width = 8, fig.asp = .69, message = FALSE}
library(colorblindr)
cvd_grid(fig)
```

Then inspect it in the interactive app:
```{r eval = FALSE}
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`:
```{r iris-OkabeIto, fig.width = 5, fig.asp = .69}
fig2 <- ggplot(iris, aes(Sepal.Length, fill = Species)) +
geom_density(alpha = 0.7) + scale_fill_OkabeIto()
fig2
```

That figure after color-vision-deficiency simulation:
```{r iris-OkabeIto-cvd, fig.width = 8, fig.asp = .69, message = FALSE}
cvd_grid(fig2)
```