draw-key-path

Draw-key returning a short polyline.

Useful for path-like geoms where a single straight stroke is misleading.

Usage

draw-key-path()

Returns

Draw-key dictionary consumed by the legend renderer.

Examples

Short polyline glyph that hints at a non-monotonic path.

#let d = (
  (x: 1, y: 1, g: "a"),
  (x: 2, y: 2, g: "a"),
  (x: 1, y: 3, g: "b"),
  (x: 2, y: 1, g: "b"),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", colour: "g"),
  layers: (geom-path(key: draw-key-path()),),
  width: 8cm,
  height: 5cm,
)

Path chart of two colour-coded trajectories with the legend showing a small zigzag polyline glyph in place of a straight stroke.

Path chart of two colour-coded trajectories with the legend showing a small zigzag polyline glyph in place of a straight stroke.

Use the path glyph for trajectory-style line layers to make the legend visually consistent with the data.

#let d = range(0, 24).map(t => (
  x: calc.cos(t * 0.4), y: calc.sin(t * 0.4) * (t / 24 + 0.5), g: "trajectory",
))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", colour: "g"),
  layers: (geom-path(stroke: 1pt, key: draw-key-path()),),
  width: 8cm,
  height: 5cm,
)

Path chart tracing an expanding spiral trajectory with a legend glyph that mirrors the winding shape using a polyline swatch.

Path chart tracing an expanding spiral trajectory with a legend glyph that mirrors the winding shape using a polyline swatch.

See also

draw-key-point, draw-key-line, draw-key-rect, draw-key-blank.

Back to top