scale-linewidth-manual

Manual discrete linewidth scale: supply a per-level array of Typst lengths.

Use when each level should map to a chosen thickness rather than the evenly-spaced range that the discrete inference would assign.

Usage

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

Parameters

Parameter Default Description
values () Array of Typst lengths, 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 thin/medium/thick strokes.

#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", linewidth: "g", group: "g"),
  layers: (geom-line(),),
  scales: (scale-linewidth-manual(values: (0.4pt, 1pt, 2pt)),),
  width: 10cm,
  height: 6cm,
)

Line chart of three groups along x against y where manual values pin group a to a thin stroke, b to medium, and c to a thick stroke.

Line chart of three groups along x against y where manual values pin group a to a thin stroke, b to medium, and c to a thick stroke.

See also

scale-linewidth-continuous, scale-linewidth-identity.

Back to top