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