scale-gradient

Two-colour continuous gradient colour/fill scale.

Interpolates between low and high.

Usage

scale-gradient(
  ..args,
)

Parameters

Parameter Default Description
..args Named arguments forwarded to the colour/fill scale (e.g. low, high, name, limits, breaks, labels).

Returns

Deferred scale spec consumed by scales.

Examples

Interpolate a numeric fill between two colours.

#let d = range(1, 8).map(i => (x: i, y: i, w: i))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", fill: "w"),
  layers: (geom-point(size: 5pt),),
  scales: scales(fill: scale-gradient(low: rgb("#132B43"), high: rgb("#56B1F7"))),
  width: 10cm,
  height: 6cm,
)

Scatter chart of seven diagonal points whose fill interpolates between a low and high colour with a numeric column.

Scatter chart of seven diagonal points whose fill interpolates between a low and high colour with a numeric column.

See also

scales, scale-gradient2, scale-gradientn.

Back to top