scale-size-manual

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

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

Usage

scale-size-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 small/medium/large markers.

#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", size: "g", group: "g"),
  layers: (geom-point(fill: rgb("#1f77b4")),),
  scales: (scale-size-manual(values: (2pt, 4pt, 7pt)),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of three groups where manual values pin group a to a small marker, b to medium, and c to large in a fixed discrete cycle.

Scatter chart of three groups where manual values pin group a to a small marker, b to medium, and c to large in a fixed discrete cycle.

See also

scale-size-continuous, scale-radius.

Back to top