scale-colour-steps2
Binned diverging colour gradient through a midpoint.
Quantises the trained continuous domain into n-breaks equal-width bins using a three-stop palette that pivots through mid at midpoint.
Usage
scale-colour-steps2(
..args,
)Parameters
| Parameter | Default | Description |
|---|---|---|
..args |
Returns
Scale object consumed by plot.
Examples
Six-bin diverging discretisation pivoting at zero.
#let d = range(-5, 6).map(i => (x: i, y: i, z: i))
#plot(
data: d,
mapping: aes(x: "x", y: "y", colour: "z"),
layers: (geom-point(size: 3pt),),
scales: (scale-colour-steps2(midpoint: 0, n-breaks: 6),),
width: 10cm,
height: 6cm,
)Shift midpoint and adjust the three stops to highlight a non-zero pivot.
#let d = range(0, 11).map(i => (x: i, y: i, z: i))
#plot(
data: d,
mapping: aes(x: "x", y: "y", colour: "z"),
layers: (geom-point(size: 3pt),),
scales: (scale-colour-steps2(
low: rgb("#1a9850"),
mid: rgb("#ffffbf"),
high: rgb("#d73027"),
midpoint: 5,
n-breaks: 8,
),),
width: 10cm,
height: 6cm,
)