scale-fill-manual
Manual discrete fill scale: supply the colour array directly.
Colours cycle through values in the order levels appear, unless limits fixes the level order.
Usage
scale-fill-manual(
..args,
)Parameters
| Parameter | Default | Description |
|---|---|---|
..args |
Returns
Scale object consumed by plot.
Examples
Hand-picked colour array applied to three categorical levels.
#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-manual(values: (
rgb("#66c2a5"), rgb("#fc8d62"), rgb("#8da0cb"),
)),),
width: 10cm,
height: 6cm,
)The same array shown as a swatch strip via geom-rect.
#let pal = (rgb("#66c2a5"), rgb("#fc8d62"), rgb("#8da0cb"))
#let d = pal.enumerate().map(((i, _)) => (
xmin: i, xmax: i + 1, ymin: 0, ymax: 1, k: str(i),
))
#plot(
data: d,
mapping: aes(xmin: "xmin", xmax: "xmax", ymin: "ymin", ymax: "ymax", fill: "k"),
layers: (geom-rect(),),
scales: (scale-fill-manual(values: pal),),
guides: guides(fill: guide-none()),
width: 6cm,
height: 1cm,
)