scale-colour-gradient

Continuous two-stop colour gradient.

Linearly interpolates between low and high across the trained domain. Defaults to a blue ramp.

Usage

scale-colour-gradient(
  ..args,
)

Parameters

Parameter Default Description
..args

Returns

Scale object consumed by plot.

Examples

Default low-to-high blue 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-gradient(),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of twelve diagonal points coloured by z along the default two-stop gradient ramp from dark navy at low to light sky-blue at high.

Scatter chart of twelve diagonal points coloured by z along the default two-stop gradient ramp from dark navy at low to light sky-blue at high.

Custom two-stop ramp passing explicit low and high colours.

#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-gradient(
    low: rgb("#fee5d9"),
    high: rgb("#a50f15"),
  ),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of twelve diagonal points coloured by z along a custom two-stop ramp from pale peach at low values to deep crimson at high values.

Scatter chart of twelve diagonal points coloured by z along a custom two-stop ramp from pale peach at low values to deep crimson at high values.

See also

scale-colour-gradient2, scale-colour-gradientn, scale-fill-gradient.

Back to top