-
Notifications
You must be signed in to change notification settings - Fork 9
/
README.Rmd
78 lines (57 loc) · 2.14 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
---
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "figure/",
fig.height = 1
)
```
# Beyoncé Palettes
This is a shameless theft/mashup of:
1. [Brendan Hurr's idea](https://twitter.com/bhive01/status/663910585461968896) ([also Karthik's](https://twitter.com/_inundata/status/663910271212122112)) from [Noam Ross's tweet](https://twitter.com/noamross/status/663907049244196864)
2. Code from [Karthik Ram's `wesanderson` palette](https://github.com/karthik/wesanderson)
3. **Foremost**: the 130 amazing palettes from [beyoncepalettes.tumblr.com](http://beyoncepalettes.tumblr.com/)
**Note**: I am (red-green) colourblind. I have no idea whether these colours make sense for data visualisation. Maybe [use `viridis`](https://github.com/sjmgarnier/viridis) if you want people like me to be able to see your plots :)
## Installation
```R
devtools::install_github("dill/beyonce")
```
## Usage
```{r, palettes_dummy}
library(beyonce)
```
```{r, all_palettes, fig.width=5, fig.height=26}
par(mfrow=c(26,5))
for(i in 1:130) print(beyonce_palette(i))
```
```{r, iris_ex, fig.height = 3}
library(ggplot2)
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point(size = 3) +
scale_color_manual(values = beyonce_palette(18)) +
theme_gray()
```
```{r, mtcars_ex, fig.height = 3}
qplot(factor(cyl), data=mtcars, geom="bar", fill=factor(vs)) +
scale_fill_manual(values = beyonce_palette(72))
```
```{r, volcano_ex, fig.height = 5, fig.width=5}
pal <- beyonce_palette(123, 21, type = "continuous")
image(volcano, col = pal, asp=1)
```
```{r, heatmap_ex, fig.height = 3}
pal <- beyonce_palette(3, 100, type = "continuous")
# heatmap is a local dataset
ggplot(heatmap, aes(x = X2, y = X1, fill = value)) +
geom_tile() +
scale_fill_gradientn(colours = pal) +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0, 0)) +
coord_equal()
```
## Hex values
If you just like the hex values of the palettes, they are available [at this gist](https://gist.github.com/dill/fb75131e618c52564fc9) (one per line).
With apologies, DLM