“The greatest value of a picture is when it forces us to notice what we never expected to see.” - John Tukey
Color is one of the most important attributes of a figure. Dedicated choice of color can help us deliver our idea more vividly.
The goal of paintingr is to provide a set of palettes from paintings.
Structure of the package was based on coding from the wesanderson packages.
You can install the paintingr with:
install.packages('paintingr')
Or the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("thereallda/paintingr")
library(paintingr)
# display all palettes
display_all_palettes()

Girl with a Pearl Earring - Johannes Vermeer (1665), Source
paint_palette("Pearlgirl")

A Bigger Splash - David Hockney (1967), Source
paint_palette("Splash")

Autumn at Oirase - Kawase Hasui (1933), Source
paint_palette("Autumn")

Matin à Villeneuve - Henri Biva (1905), Source
paint_palette("Villeneuve")

Ophelia - John Everett Millais (1851-1852), Source
paint_palette("Ophelia")

SPRING BY THE SEINE - Claude Monet (1875), Source
paint_palette("Spring")

Strawberries - Édouard Manet (1882), Source
paint_palette("Strawberries")

Seascape at Saintes-Maries - Vincent van Gogh (1888), Source
paint_palette("Seascape")

Twilight, Venice - Claude Monet (1908), Source
paint_palette("Twilight")

Abstract Composition - Jessica Dismorr (1915), Source
paint_palette("Abstract")

Vesuvius in Eruption - Joseph Wright (1776-1780), Source
paint_palette("Vesuvius")

Sunset at Grace, Orange and Violet Sky - Felix Edouard Vallotton (1918), Source
paint_palette("Sunset")

Caront - Guim Tió Zarraluki (2019), Source
paint_palette("Caront")

The Starry Night - Vincent van Gogh (1889), Source
paint_palette("Starrynight")

ggplot2-based examples
Use type="continuous" to automatically interpolate between colors if you want more colors than the palette can offer (n > 5/6).
library(ggplot2)
# Dummy data
x <- LETTERS[1:20]
y <- paste0("var", seq(1,20))
data <- expand.grid(X=x, Y=y)
data$Z <- seq(1,20)+runif(400, 0, 5)
# Heatmap
pal <- paint_palette("Sunset", n=100, type="continuous")
ggplot(data, aes(X, Y, fill= Z)) +
geom_tile() +
scale_fill_gradientn(colours = pal) +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0, 0)) +
coord_equal()

# Heatmap with palette of "Starrynight"
ggplot(data, aes(X, Y, fill= Z)) +
geom_tile() +
scale_fill_gradientn(colours = paint_palette("Starrynight", n=100, type="continuous")) +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0, 0)) +
coord_equal()

# Heatmap with palette of "Vesuvius"
ggplot(data, aes(X, Y, fill= Z)) +
geom_tile() +
scale_fill_gradientn(colours = paint_palette("Vesuvius", n=100, type="continuous")) +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0, 0)) +
coord_equal()

# use iris data from `ggplot2` for demonstration
data(iris)
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot(aes(fill = Species)) +
theme_classic() +
theme(legend.position = "top") +
scale_fill_manual(values = paint_palette("Pearlgirl"))

# Scatter
ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_point(aes(color = Species)) +
theme_classic() +
theme(legend.position = "top") +
scale_color_manual(values = paint_palette("Caront"))

data(mpg)
# violin plot with 7 colors, Spring palette only have six colors add one more
ggplot(mpg, aes(x=class, y=hwy, fill=class)) +
geom_violin() +
theme_classic() +
scale_fill_manual(values = c(paint_palette("Twilight", type = "continuous", n=7)))

ggplot(mpg, aes(x = class, fill = drv)) +
geom_bar() +
theme_classic() +
scale_fill_manual(values = paint_palette("Seascape"))