scale-alpha-manual

Manual discrete alpha scale: supply a per-level array of opacities.

Use when each level should map to a chosen opacity in [0, 1] rather than the evenly-spaced range that the discrete inference would assign.

Usage

scale-alpha-manual(
  values: (),
  name: none,
  limits: none,
  labels: auto,
)

Parameters

Parameter Default Description
values () Array of opacities in [0, 1], one per level (in limits order when set, otherwise in first-seen order).
name none Legend title. Overrides any name set via labs when both are present.
limits none Array of level names controlling order and inclusion, or none.
labels auto Array of legend labels aligned with limits, or auto.

Returns

Scale object consumed by plot.

Examples

Three groups assigned dim/medium/full opacity.

#let d = (
  (x: 1, y: 1, g: "a"), (x: 2, y: 2, g: "a"),
  (x: 1, y: 2, g: "b"), (x: 2, y: 3, g: "b"),
  (x: 1, y: 3, g: "c"), (x: 2, y: 4, g: "c"),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", alpha: "g", group: "g"),
  layers: (geom-point(size: 4pt, fill: rgb("#1f77b4")),),
  scales: (scale-alpha-manual(values: (0.2, 0.55, 1)),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of three blue groups where manual values pin group a to dim opacity, b to medium, and c to full opaque with a fixed discrete cycle.

Scatter chart of three blue groups where manual values pin group a to dim opacity, b to medium, and c to full opaque with a fixed discrete cycle.

See also

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

Back to top