“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.
Installation
You can install the paintingr
with:
install.packages('paintingr')
Or the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("thereallda/paintingr")
Usage
library(paintingr)
# display all palettes
display_all_palettes()
Palettes
Vesuivus
Vesuvius in Eruption - Joseph Wright of Derby (1776-1780), Source
paint_palette("Vesuvius")
Examples
ggplot2
-based examples
Heatmap
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("Autumn", 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 "Vesuvius"
pal2 <- paint_palette("Vesuvius", n=100, type="continuous")
ggplot(data, aes(X, Y, fill= Z)) +
geom_tile() +
scale_fill_gradientn(colours = pal2) +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0, 0)) +
coord_equal()
Boxplot
# 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("Villeneuve"))
Scatter
# 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("Kitchen"))
Violin plot
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("Spring", n=6), "black"))
Barplot
ggplot(mpg, aes(x = class, fill = drv)) +
geom_bar() +
theme_classic() +
scale_fill_manual(values = paint_palette("Ophelia"))