scale-gradient2

Diverging three-colour gradient colour/fill scale.

Interpolates low-mid-high around midpoint.

Usage

scale-gradient2(
  ..args,
)

Parameters

Parameter Default Description
..args Named arguments forwarded to the colour/fill scale.

Keys accepted by ..args:

  • low: Bin or ramp low-end colour; default rgb("#1F77B4").
  • mid: Bin or ramp midpoint colour; default rgb("#FFFFFF").
  • high: Bin or ramp high-end colour; default rgb("#D62728").
  • midpoint: Data value placed at mid, in data units; default 0.
  • name: Axis or legend title, as a string or content; none (default) falls back to the mapped column name.
  • limits: Domain as a (lo, hi) pair, where either side may be auto to train that side from the data; none (default) trains both sides.
  • oob: Handling of rows outside limits: "drop" (default) removes them, "squish" clamps them to the nearest limit.
  • breaks: Array of tick positions in data units, a bare number for a single tick, a function of the trained values returning positions (the breaks-* helpers return such a function), or auto (default) for computed breaks.
  • labels: Array of labels aligned with the breaks, a function of the break value returning a string or content (the format-* helpers return such a function), or auto (default) to format each break.

Returns

Deferred scale spec consumed by scales.

Examples

Diverge a signed numeric fill around zero.

#let d = range(0, 11).map(i => (x: i, y: i, w: i - 5))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", fill: "w"),
  layers: (geom-point(size: 5pt),),
  scales: scales(fill: scale-gradient2(midpoint: 0)),
  width: 10cm,
  height: 6cm,
)

Scatter chart of eleven diagonal points whose fill diverges from a low colour through white to a high colour around a midpoint of zero.

Scatter chart of eleven diagonal points whose fill diverges from a low colour through white to a high colour around a midpoint of zero.

See also

scales, scale-gradient, scale-gradientn.

Back to top