-
Notifications
You must be signed in to change notification settings - Fork 29
/
README.Rmd
67 lines (51 loc) · 1.88 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{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)
```