Skip to contents

A sketch-style theme based on ggplot2::theme_bw() with a muted palette to match the rough geoms. Light (default) and dark presets are available via dark. The sketchiness of the marks comes from the geoms themselves; this theme styles the surrounding frame, typography, and background.

Usage

theme_sketch(
  base_size = 11,
  base_family = getOption("ggsketch.base_family", ""),
  base_line_size = base_size/22,
  base_rect_size = base_size/22,
  dark = FALSE,
  rough_frame = FALSE,
  roughness = 0.5,
  paper = "none",
  seed = NULL
)

Arguments

base_size

Base font size (default 11).

base_family

Base font family. Defaults to getOption("ggsketch.base_family", ""); "" uses the device default. "auto" picks the first installed handwriting font, the one sketch_font() returns, falling back to the device default. Set options(ggsketch.base_family = "auto") to make every sketch plot's text (titles, axes, legend) use handwriting, not just the labels drawn by geom_sketch_text() / geom_sketch_bracket(). Or pass an explicit family name.

base_line_size

Line size (default base_size / 22).

base_rect_size

Rect size (default base_size / 22).

dark

If TRUE, use the dark "chalkboard" preset. Default FALSE (light "paper" preset). On ggplot2 >= 4.0 the geoms' default ink switches to a light colour too, so marks without a mapped or set colour stay visible.

rough_frame

If TRUE, draw the frame itself hand-drawn: the major gridlines, panel border, axis ticks, facet strip backgrounds, and the continuous-scale colourbar frame and ticks become roughened sketch grobs (via element_sketch_line() / element_sketch_rect()) so the whole frame matches the marks. Default FALSE.

roughness

Roughness for the rough frame (only used when rough_frame = TRUE). Default 0.5.

paper

Paper ground drawn behind the data: one of sketch_papers() ("none" (default), "notebook", "graph", "dotted", "aged", "blueprint", "chalkboard", "kraft", "legal_pad", "index_card", "whiteboard"). A non-"none" paper paints a simulated texture as the panel background, recolours the plot ground and text to suit it (light text on the dark blueprint / chalkboard grounds, and on ggplot2 >= 4.0 light default geom ink as well), and suppresses the default gridlines where the paper supplies its own ruling.

seed

Integer seed for the rough frame, for reproducible wobble. NULL uses getOption("ggsketch.seed", 1L).

Value

A ggplot2::theme object.

Examples

library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg)) + geom_sketch_point(seed = 1L)
p + theme_sketch()

p + theme_sketch(dark = TRUE)

p + theme_sketch(rough_frame = TRUE)

p + theme_sketch(paper = "notebook")