scale-colour-stepsn
Binned n-stop colour gradient.
Walks colours as a sequence of stops and quantises the lookup into n-breaks equal-width bins.
Usage
scale-colour-stepsn(
colours,
n-breaks,
breaks,
name,
limits,
oob,
labels,
)Parameters
| Parameter | Default | Description |
|---|---|---|
colours |
Array of two or more colours. | |
n-breaks |
Number of bins to partition the domain into. Ignored when breaks is set. |
|
breaks |
Array of bin edges, or auto to derive equal-width bins from n-breaks. Edges define the bin boundaries; n-breaks is ignored when set. |
|
name |
Legend title. Overrides any name set via labels when both are present. |
|
limits |
Pair (lo, hi) clipping the trained domain, 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 the bins, or auto. |
Returns
Scale object consumed by plot.
Examples
Three-stop ramp discretised into six bins.
#let d = range(0, 12).map(i => (x: i, y: i, z: i * 0.5))
#plot(
data: d,
mapping: aes(x: "x", y: "y", colour: "z"),
layers: (geom-point(size: 3pt),),
scales: (scale-colour-stepsn(colours: (
rgb("#1a9850"), rgb("#ffffbf"), rgb("#d73027"),
), n-breaks: 6),),
width: 10cm,
height: 6cm,
)Reuse a brewer palette as the stop list to fold a discrete palette into a banded continuous scale.
#let d = range(0, 12).map(i => (x: i, y: i, z: i * 0.5))
#plot(
data: d,
mapping: aes(x: "x", y: "y", colour: "z"),
layers: (geom-point(size: 3pt),),
scales: (scale-colour-stepsn(
colours: brewer-palette("YlOrRd"),
n-breaks: 5,
),),
width: 10cm,
height: 6cm,
)