scale-fill-brewer
Discrete ColorBrewer fill scale.
Fill counterpart of scale-colour-brewer. Same palette names apply.
Usage
scale-fill-brewer(
palette,
name,
limits,
oob,
labels,
)Parameters
| Parameter | Default | Description |
|---|---|---|
palette |
ColorBrewer palette name (qualitative, sequential, or diverging). | |
name |
Legend title. Overrides any name set via labs when both are present. |
|
limits |
Array of level names controlling order and inclusion, or none. |
|
oob |
Out-of-range policy: "drop" (default) removes rows whose value falls outside limits; "squish" clamps continuous values to the nearest endpoint. |
|
labels |
Array of legend labels aligned with limits, or auto. |
Returns
Scale object consumed by plot.
Examples
Set1 palette filling categorical bars.
#let d = (
(grp: "a", y: 1),
(grp: "b", y: 2),
(grp: "c", y: 3),
)
#plot(
data: d,
mapping: aes(x: "grp", y: "y", fill: "grp"),
layers: (geom-col(),),
scales: (scale-fill-brewer(palette: "Set1"),),
width: 10cm,
height: 6cm,
)The Spectral palette laid out as a swatch strip via geom-rect.
#let levels = ("a", "b", "c", "d", "e", "f", "g")
#let d = levels.enumerate().map(((i, k)) => (
xmin: i, xmax: i + 1, ymin: 0, ymax: 1, k: k,
))
#plot(
data: d,
mapping: aes(xmin: "xmin", xmax: "xmax", ymin: "ymin", ymax: "ymax", fill: "k"),
layers: (geom-rect(),),
scales: (scale-fill-brewer(palette: "Spectral"),),
guides: guides(fill: none),
theme: theme-void(),
width: 8cm,
height: 1cm,
)