-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
101 lines (81 loc) · 2.72 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# Colorblind-friendly Palettes from Washington State
<!-- badges: start -->
[![R-CMD-check](https://github.com/CoryMcCartan/wacolors/workflows/R-CMD-check/badge.svg)](https://github.com/CoryMcCartan/wacolors/actions)
<!-- badges: end -->
![Mt. Rainier](cover.jpg)
The `wacolor` package contains `r length(wacolors::wacolors)` color palettes
taken from the landscapes and cities of Washington state. Each color was
extracted from a photograph, with minor alterations made to improve balance
and desaturability. The palettes were evaluated by the color-blind author to
ensure colors are distinguishable, but some palettes risk more confusion than
others, especially at small scales.
## Installation
<!-- You can install the released version of wacolors from [CRAN](https://CRAN.R-project.org) with: -->
You can install `wacolors` from GitHub with:
``` r
devtools::install_github("CoryMcCartan/wacolors@release")
```
## Usage
It's easy to select a palette. Access palettes through `wacolors$...` for
autocompletion suggestions.
```{r}
library(wacolors)
library(ggplot2)
# See all palettes
names(wacolors)
# See one palette
wacolors$rainier
```
The package comes with `ggplot2`-compatible scales which are easy to use.
```{r ggplot}
# access by name
ggplot(mtcars, aes(mpg, wt)) +
geom_point(aes(color = factor(cyl), size=hp)) +
scale_color_wa_d("seattle_night")
# or access using `wacolors$...`
ggplot(diamonds) +
geom_bar(aes(x = cut, fill = clarity)) +
scale_fill_wa_d(wacolors$sound_sunset, reverse=TRUE)
```
You can use the `wa_pal` function to directly construct a discretized/binned
color scale.
```{r heatmap}
image(volcano, col=wa_pal("ferries", 12))
image(volcano, col=wa_pal("volcano", 80, reverse=TRUE))
```
### Code Generation
In case you do not wish to have `wacolors` as a dependency, you may use the
`pal_vector()` and `pal_functions()` functions, which generate self-contained
code for using the palettes. When using RStudio, this code will be loaded,
ready to copy, at the console prompt.
```{r}
pal_vector("sound_sunset", 15)
pal_functions("locks")
```
## The Palettes
### Continuous Palettes
```{r cont-palettes, echo=F, fig.height=1, out.width=NULL}
cont_pal = c("sound_sunset", "understory", "winter_mountain", "ferries",
"forest_fire", "volcano", "locks", "plane_view")
for (pal in cont_pal) {
plot(wa_pal(pal, 256))
}
```
### All Palettes
```{r disc-palettes, echo=F, fig.height=1, out.width=NULL}
for (pal in names(wacolors)) {
plot(wa_pal(pal))
}
```