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.
- Host: GitHub
- URL: https://github.com/clauswilke/colorblindr
- Owner: clauswilke
- License: mit
- Created: 2017-08-13T21:42:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-17T15:07:59.000Z (over 1 year ago)
- Last Synced: 2025-02-14T12:13:32.384Z (7 days ago)
- Language: R
- Homepage:
- Size: 4.13 MB
- Stars: 316
- Watchers: 13
- Forks: 30
- Open Issues: 9
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - clauswilke/colorblindr - An R package to simulate colorblindness on R figures. (R)
README
---
output: github_document
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```# colorblindr
[](https://travis-ci.org/clauswilke/colorblindr)
[](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)
```