scale-shape-manual

Manual discrete shape scale: supply the shape-keyword array directly.

Keywords cycle through values in the order levels appear, unless limits fixes the level order.

Usage

scale-shape-manual(
  values: (),
  name: none,
  limits: none,
  oob: "drop",
  labels: auto,
)

Parameters

Parameter Default Description
values () Array of shape keywords or literal-glyph characters, one per level.
name none Legend title. Overrides any name set via labels when both are present.
limits none Array of level names controlling order and inclusion, or none.
oob "drop" Out-of-range policy: "drop" (default) removes rows whose value falls outside limits; "squish" clamps continuous values to the nearest endpoint.
labels auto Array of legend labels aligned with limits, or auto.

Returns

Scale object consumed by plot.

Examples

Custom three-shape cycle assigned in input order.

#let d = (
  (x: 1, y: 2, sp: "a"),
  (x: 2, y: 4, sp: "b"),
  (x: 3, y: 3, sp: "c"),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", shape: "sp"),
  layers: (geom-point(size: 3pt),),
  scales: (scale-shape-manual(
    values: ("circle", "triangle", "diamond"),
  ),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of three points where the manual values pin sp to a circle, triangle, and diamond glyph in the order levels first appear.

Scatter chart of three points where the manual values pin sp to a circle, triangle, and diamond glyph in the order levels first appear.

limits pins the level order so the shape mapping stays stable across datasets.

#let d = (
  (x: 1, y: 3, sp: "c"),
  (x: 2, y: 4, sp: "a"),
  (x: 3, y: 2, sp: "b"),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", shape: "sp"),
  layers: (geom-point(size: 4pt),),
  scales: (scale-shape-manual(
    values: ("circle", "triangle", "diamond"),
    limits: ("a", "b", "c"),
  ),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of three points where limits forces a, b, c order so the circle, triangle, diamond mapping stays stable regardless of input order.

Scatter chart of three points where limits forces a, b, c order so the circle, triangle, diamond mapping stays stable regardless of input order.

Map levels to letters so each marker is drawn as a literal glyph rather than a built-in shape.

#let d = (
  (x: 1, y: 2, sp: "a"),
  (x: 2, y: 4, sp: "b"),
  (x: 3, y: 3, sp: "c"),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", shape: "sp"),
  layers: (geom-point(size: 5pt),),
  scales: (scale-shape-manual(
    values: ("A", "B", "C"),
  ),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of three points where the manual values render the letters A, B, C as the marker glyphs.

Scatter chart of three points where the manual values render the letters A, B, C as the marker glyphs.

See also

scale-shape, geom-point.

Back to top