scale-colour-brewer
Discrete ColorBrewer colour scale.
palette selects a named ColorBrewer palette such as "Set1", "Dark2", or "Spectral". Categorical levels are mapped to colours in the order they first appear in the data.
Usage
scale-colour-brewer(
..args,
)Parameters
| Parameter | Default | Description |
|---|---|---|
..args |
Returns
Scale object consumed by plot.
Examples
Set1 palette mapping three categorical levels to bold qualitative hues.
#let d = (
(x: 1, y: 2, sp: "a"),
(x: 2, y: 4, sp: "b"),
(x: 3, y: 3, sp: "c"),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y", colour: "sp"),
layers: (geom-point(size: 3pt),),
scales: (scale-colour-brewer(palette: "Set1"),),
width: 10cm,
height: 6cm,
)Switching to the diverging Spectral palette suits ordered categories with a meaningful midpoint.
#let d = (
(x: 1, y: 2, sp: "low"),
(x: 2, y: 3, sp: "mid"),
(x: 3, y: 4, sp: "high"),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y", colour: "sp"),
layers: (geom-point(size: 3pt),),
scales: (scale-colour-brewer(
palette: "Spectral",
limits: ("low", "mid", "high"),
),),
width: 10cm,
height: 6cm,
)