Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/dill/beyonce

:crown: :bee: :bar_chart: Beyoncé colour palettes for R
https://github.com/dill/beyonce

Last synced: 3 months ago
JSON representation

:crown: :bee: :bar_chart: Beyoncé colour palettes for R

Awesome Lists containing this project

README

        

---
---

```{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