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

Scatter chart of eleven points where z is cut into six stepped bands along a diverging ramp that pivots through white at zero, green for negative and red for positive.

Scatter chart of eleven points where z is cut into six stepped bands along a diverging ramp that pivots through white at zero, green for negative and red for positive.

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

Scatter chart of eleven points where z is cut into eight stepped bands along a green-yellow-red diverging ramp pivoting through pale yellow at midpoint 5.

Scatter chart of eleven points where z is cut into eight stepped bands along a green-yellow-red diverging ramp pivoting through pale yellow at midpoint 5.

See also

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

Back to top