geom-path

Path layer connecting observations in row order, one path per group.

Grouping is implicit on discrete aesthetics (colour, fill, linetype) or the explicit group mapping, just like geom-line.

Usage

geom-path(
  mapping: none,
  data: none,
  stroke: auto,
  colour: auto,
  alpha: auto,
  linetype: auto,
  key: auto,
  stat: "identity",
  position: "identity",
  inherit-aes: true,
)

Parameters

Parameter Default Description
mapping none Layer-specific aesthetic mapping built with aes. Falls back to the plot mapping when none.
data none Layer-specific dataset, or a function applied to the plot data returning the layer frame. Falls back to the plot data when none.
stroke auto Line thickness (a Typst length).
colour auto Fixed line colour. auto resolves via the colour scale or a neutral default.
alpha auto Line opacity in [0, 1].
linetype auto Dash keyword (e.g., "solid", "dashed"). auto honours the linetype scale.
key auto Legend glyph override built with a draw-key-* helper. auto picks the default for the geom.
stat "identity" Statistical transform name. Usually "identity".
position "identity" Position adjustment name. Usually "identity".
inherit-aes true Whether to merge the plot-level mapping into this layer’s mapping.

Returns

Layer dictionary consumed by plot.

Examples

Connect rows in input order (deliberately not sorted by x).

#let d = (
  (x: 1, y: 1), (x: 3, y: 4), (x: 2, y: 2), (x: 4, y: 5),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-path(stroke: 1pt),),
  width: 10cm,
  height: 6cm,
)

Polyline connecting four (x, y) rows in their input order along a zig-zag path rather than sorted by x.

Polyline connecting four (x, y) rows in their input order along a zig-zag path rather than sorted by x.

Trajectory of a moving point parameterised by t, drawn in time order with a coloured fade.

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

Spiralling trajectory in (x, y) of a particle parameterised by t with the path coloured by t via colour aesthetic.

Spiralling trajectory in (x, y) of a particle parameterised by t with the path coloured by t via colour aesthetic.

See also

geom-line, geom-step, geom-segment.

Back to top