It’s a hot summer’s day and you’re sipping on your 2-for-£12 pitchers from your local spoons (https://www.jdwetherspoon.com/ for you uncultured swines). ‘Wow, what a pretty cocktail I’m drinking’, you think to yourself. ‘If only I could use these colours on my next coursework assignment’. Well fear not…
This package provides palettes inspired by the cocktails of JD
Wetherspoon (and by the amazing
MetBrewer
).
Feel free to contact me with comments or suggestions:
LinkedIn:
@dougal-toms
Twitter:
@DougalToms
wetherspoons
can be installed through GitHub
install.packages("devtools")
devtools::install_github("dougaltoms/wetherspoons")
pip install git+https://github.com/dougaltoms/wetherspoons.git
An overview of available cocktail palettes can be had with the
WhatsOnTheMenu()
function:
library(wetherspoons)
wetherspoons::WhatsOnTheMenu()
Once you’ve chosen your cocktail, you can generate colour values by
ordering a pitcher of, using the pitcher.of()
function:
wetherspoons::pitcher.of("BlueLagoon")
## [1] "#164D83" "#2A81CA" "#3CA2E1" "#55CCE3" "#80BCAE" "#F2E554"
Plotting 2D hillshaded maps using rayshader
and wetherspoons
library(rayshader)
palette <- wetherspoons::pitcher.of("TuttiFrutti", n=250, direction=1)
montereybay %>%
height_shade(texture=palette) %>%
add_overlay(sphere_shade(montereybay, zscale=4), alphalayer=.5) %>%
plot_map()
wetherspoons
provides relevant scales for use with ggplot2
. The following examples use the commonly used iris
data set.
library(ggplot2)
ggplot(iris, aes(x = Petal.Length, fill = Species)) +
geom_density(alpha = 0.8)+
scale_fill_manual(values=pitcher.of("BlueLagoon",3))+
labs(x="Petal length", y="Density",
title="How petal length varies across Iris species",
subtitle="Coloured using wetherspoons")+
theme_minimal()
library(ggplot2)
ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) +
geom_point(size=2) +
scale_color_manual(values=pitcher.of("SexOnTheBeach",3))+
labs(x="Length", y="Width",
title="Length of Iris sepals plotted against their width",
subtitle = "Coloured using wetherspoons")+
theme_minimal()
library(ggplot2)
ggplot(data=iris, aes(x=Species, y=Petal.Length, fill=Species)) +
geom_violin() +
scale_fill_manual(values=pitcher.of("PurpleRain",n=3, direction=1))+
labs(title="Petal length by Iris Species", y="Petal length",
subtitle="Coloured using wetherspoons")+
theme_minimal()
wetherspoons
provides matplotlib
functionality with the ability to create custom cmaps
import matplotlib.pyplot as plt
import numpy as np
# Create wetherspoons cmap
cmap = wetherspoons.pitcher_of("BlueLagoon", direction=1, type="continuous")
# Create data
X, Y = np.meshgrid(np.linspace(-3, 3, 16), np.linspace(-3, 3, 16))
Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2)
# Plot
fig, ax = plt.subplots()
ax.imshow(Z, cmap=cmap)
plt.show()