scale-alpha-continuous

Continuous alpha (opacity) scale mapping a numeric column to opacities.

Usage

scale-alpha-continuous(
  name: none,
  range: (0.1, 1),
  limits: none,
  breaks: auto,
  labels: auto,
)

Parameters

Parameter Default Description
name none Legend title. Overrides any name set via labs when both are present.
range (0.1, 1) Pair (lo, hi) bounding the output opacity, each in [0, 1].
limits none Pair (lo, hi) clipping the trained domain, or none.
breaks auto Array of break values for the legend, or auto.
labels auto Array of legend labels aligned with breaks, or auto.

Returns

Scale object consumed by plot.

Examples

Linear opacity mapping with a wide range to fade points from near-transparent to fully opaque.

#let d = range(0, 12).map(i => (x: i, y: i, w: i + 1))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", alpha: "w"),
  layers: (geom-point(size: 4pt),),
  scales: (scale-alpha-continuous(range: (0.1, 1)),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of twelve diagonal points where w drives opacity along a continuous ramp from near-transparent at low values to fully opaque at high.

Scatter chart of twelve diagonal points where w drives opacity along a continuous ramp from near-transparent at low values to fully opaque at high.

A narrower range keeps every point visible while still encoding magnitude.

#let d = range(0, 12).map(i => (x: i, y: i, w: i + 1))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", alpha: "w"),
  layers: (geom-point(size: 4pt),),
  scales: (scale-alpha-continuous(range: (0.4, 0.9)),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of twelve diagonal points where w drives opacity along a narrower 0.4 to 0.9 range so every point stays visible while still encoding magnitude.

Scatter chart of twelve diagonal points where w drives opacity along a narrower 0.4 to 0.9 range so every point stays visible while still encoding magnitude.

See also

scale-alpha-identity, scale-colour-continuous.

Back to top