geom-rug

Marginal rug ticks at each row’s x and / or y position.

sides selects which panel edges receive ticks: any combination of b (bottom), t (top), l (left), r (right). Bottom and top sides need an x mapping; left and right sides need a y mapping. Ticks honour a mapped colour aesthetic when present.

Usage

geom-rug(
  mapping: none,
  data: none,
  sides: "bl",
  length: 0.15cm,
  stroke: 0.4pt,
  colour: auto,
  alpha: auto,
  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. Falls back to the plot data when none.
sides "bl" String of edge codes among b, t, l, r indicating which axes receive ticks.
length 0.15cm Tick length as a Typst length (e.g., 0.15cm).
stroke 0.4pt Tick thickness (a Typst length).
colour auto Fixed tick colour. auto resolves via the colour scale or theme ink.
alpha auto Tick opacity in [0, 1].
inherit-aes true Whether to merge the plot-level mapping into this layer’s mapping.

Returns

Layer dictionary consumed by plot.

Examples

Bottom and left rug ticks marking each observation’s position.

#let d = range(0, 12).map(i => (x: i, y: calc.sin(i * 0.5)))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (
    geom-point(size: 2pt),
    geom-rug(sides: "bl"),
  ),
  width: 10cm,
  height: 6cm,
)

Scatter of 12 (x, y) points along a sine curve with bottom and left rug ticks marking each observation's x and y.

Scatter of 12 (x, y) points along a sine curve with bottom and left rug ticks marking each observation's x and y.

Rug on every side, coloured by a categorical column to expose per-group density along both axes.

#let d = ()
#for grp in ("a", "b") {
  for i in range(0, 12) {
    d.push((x: i + (if grp == "b" { 0.3 } else { 0 }), y: calc.sin(i * 0.5), grp: grp))
  }
}
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", colour: "grp", fill: "grp"),
  layers: (
    geom-point(size: 2pt),
    geom-rug(sides: "tblr"),
  ),
  width: 10cm,
  height: 6cm,
)

Scatter of two groups (a, b) with rug ticks on top, bottom, left, and right edges coloured by group via colour aesthetic.

Scatter of two groups (a, b) with rug ticks on top, bottom, left, and right edges coloured by group via colour aesthetic.

See also

geom-blank, geom-function, geom-point.

Back to top