ggwatercolor is a ggplot2 extension that draws maps and charts in the style of watercolor paint. The first model for the package was the archival map, where a soft tint follows each coastline and the open sea stays white.
The package has four parts:
-
geom_sf_wash()paints a wash that fades away from the edge of each shape. -
geom_sf_watercolor()and the chart geoms fill shapes with uneven paint. -
geom_hachure()draws land relief as fine ink lines that run down each slope. -
theme_paper()andtheme_paper_void()put the plot on off-white paper.
Installation
Install the development version from GitHub:
# install.packages("pak")
pak::pak("kjhealy/ggwatercolor")ggwatercolor needs ggplot2 4.0.0 or later.
A watercolor map
The package includes hawaii, the outlines of the eight main Hawaiian islands. Each watercolor layer draws only paint. Add geom_sf() with fill = NA to draw the outlines.
library(ggplot2)
library(ggwatercolor)
ggplot(hawaii) +
geom_sf_watercolor(seed = 1929) +
geom_sf_wash(seed = 1929) +
geom_sf(fill = NA, colour = "#5E4A36", linewidth = 0.25) +
theme_paper_void()
The wash and the paint use random noise. Set seed to get the same picture each time.
Paint each feature or each fill
geom_sf_watercolor() paints each feature separately by default. Each feature gets its own darker rim, and thin gaps of paper can show between neighbours. Use by = "fill" to paint all features of one colour as a single area.
library(patchwork)
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
nc$region <- cut(sf::st_coordinates(sf::st_centroid(sf::st_geometry(nc)))[, 1], 4)
nc_map <- function(by) {
ggplot(nc) +
geom_sf_watercolor(aes(fill = region), by = by, seed = 1) +
geom_sf_wash(data = sf::st_union(nc), seed = 1) +
geom_sf(fill = NA, colour = "#5E4A36", linewidth = 0.12) +
scale_fill_manual(values = c("#B9794F", "#CC7F8E", "#7FA07A", "#D9B25A")) +
labs(title = paste0("by = \"", by, "\"")) +
theme_paper_void() +
theme(legend.position = "none")
}
nc_map("feature") / nc_map("fill") + plot_annotation(theme = theme_paper_void())
Relief
geom_hachure() shows the shape of the land with hachures, in the manner of engraved maps. The layer needs a raster of elevation. hawaii_elevation() reads an example raster.
ggplot(hawaii) +
geom_hachure(hawaii_elevation(), seed = 1929) +
geom_sf_wash(seed = 1929) +
geom_sf(fill = NA, colour = "#7A4A2A", linewidth = 0.25) +
coord_sf(xlim = c(-158.4, -155.9), ylim = c(20.45, 21.8)) +
theme_paper_void()
Set light to a compass bearing to light the land from one side. The lines become thinner on slopes that face the light and heavier on slopes that face away. This map puts the light in the north-west.
ggplot(hawaii) +
geom_hachure(hawaii_elevation(), light = 315, seed = 1929) +
geom_sf_wash(seed = 1929) +
geom_sf(fill = NA, colour = "#7A4A2A", linewidth = 0.25) +
coord_sf(xlim = c(-158.4, -155.9), ylim = c(20.45, 21.8)) +
theme_paper_void()
Each map layer accepts monochrome = TRUE, which gives the same picture in grey.
ggplot(hawaii) +
geom_hachure(hawaii_elevation(), monochrome = TRUE, seed = 1929) +
geom_sf_wash(monochrome = TRUE, seed = 1929) +
geom_sf(fill = NA, colour = "grey20", linewidth = 0.25) +
coord_sf(xlim = c(-158.4, -155.9), ylim = c(20.45, 21.8)) +
theme_paper_void(paper = "#F5F5F5", ink = "grey20")
Charts
The same paint works on ordinary charts. geom_col_watercolor(), geom_area_watercolor(), and geom_density_watercolor() follow geom_col(), geom_area(), and geom_density(). geom_polygon_watercolor() paints any polygon. geom_point_watercolor(), geom_line_watercolor(), and geom_smooth_watercolor() paint points, lines, and smoothed lines.
ggplot(mpg, aes(class, fill = drv)) +
geom_col_watercolor(stat = "count", seed = 1) +
scale_fill_manual(values = c("#B9794F", "#4E9DB5", "#D9B25A")) +
labs(x = NULL, y = "Count", fill = "Drive") +
theme_paper()
Where painted areas overlap, blend = "multiply" darkens the overlap in the way that layers of pigment do. A lower alpha keeps the overlaps easy to read.
ggplot(mpg, aes(hwy, fill = drv)) +
geom_density_watercolor(blend = "multiply", alpha = 0.35, seed = 2) +
scale_fill_manual(values = c("#B9794F", "#4E9DB5", "#D9B25A")) +
labs(x = "Highway miles per gallon", y = "Density", fill = "Drive") +
theme_paper()
