scale-colour-gradientn
Continuous n-stop colour gradient.
Walks colours as a sequence of stops and linearly interpolates between adjacent stops. Useful for ramps that require more than two anchor colours (for example a ColorBrewer palette used as a continuous ramp).
Usage
scale-colour-gradientn(
..args,
)Parameters
| Parameter | Default | Description |
|---|---|---|
..args |
Returns
Scale object consumed by plot.
Examples
Three-stop ramp interpolating green-yellow-red across the domain.
#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-gradientn(colours: (
rgb("#1a9850"), rgb("#ffffbf"), rgb("#d73027"),
)),),
width: 10cm,
height: 6cm,
)Feeding a brewer palette into scale-colour-gradientn lifts a discrete palette into a continuous ramp.
#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-gradientn(
colours: brewer-palette("RdYlBu"),
),),
width: 10cm,
height: 6cm,
)See also
scale-colour-gradient, scale-colour-gradient2, scale-fill-gradientn.