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(
  ..args,
)

Parameters

Parameter Default Description
..args

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,
)

Scatter chart of twelve diagonal points where z is cut into six stepped bands along a custom three-stop n-stop ramp passing green through pale yellow to red.

Scatter chart of twelve diagonal points where z is cut into six stepped bands along a custom three-stop n-stop ramp passing green through pale yellow to red.

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,
)

Scatter chart of twelve diagonal points where z is cut into five stepped bands along the ColorBrewer YlOrRd palette fed as the n-stop list.

Scatter chart of twelve diagonal points where z is cut into five stepped bands along the ColorBrewer YlOrRd palette fed as the n-stop list.

See also

scale-colour-steps, scale-colour-steps2, scale-fill-stepsn.

Back to top