Skip to contents

Map a discrete variable to fill textures – the greyscale- and colour-vision-safe companion of a fill palette – via a filled mark's pattern aesthetic: mark_bar(x = g, y = n, pattern = series). Each level takes a distinct pattern_stripe()-family texture. Applies to the filled marks (bar, area, tile, rect, boxplot, violin, hull).

Usage

scale_pattern(plot, values = NULL, name = NULL)

Arguments

plot

A PlotSpec.

values

Optional textures, one per level: a character vector of builder names ("stripe", "crosshatch", "grid", "dot", "checker"), or a list of vellum_pattern objects (e.g. from pattern_stripe()). NULL (default) cycles a built-in palette of distinct textures.

name

Optional legend title.

Value

The modified PlotSpec.

Examples

df <- data.frame(g = c("a", "b", "c"), n = c(3, 5, 2))
vplot(df) |> mark_bar(x = g, y = n, pattern = g) |> scale_pattern()