geom-jitter

Scatter layer with position-jitter applied by default.

All other parameters mirror geom-point.

Usage

geom-jitter(
  mapping: none,
  data: none,
  size: auto,
  stroke: 0.5pt,
  fill: auto,
  colour: auto,
  alpha: auto,
  shape: auto,
  stat: "identity",
  position: "jitter",
  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.
size auto Marker size (a Typst length).
stroke 0.5pt Marker outline thickness; none disables the outline and the colour aesthetic.
fill auto Marker body fill. auto resolves via the fill scale or a neutral default.
colour auto Fixed marker outline colour. auto resolves via the colour scale, falling back to the theme ink.
alpha auto Marker opacity in [0, 1].
shape auto Marker shape keyword.
stat "identity" Statistical transform name.
position "jitter" Position adjustment name. Defaults to "jitter".
inherit-aes true Whether to merge the plot-level mapping into this layer’s mapping.

Returns

Layer dictionary consumed by plot.

Examples

Spread overlapping points with the default jitter amount.

#let d = ()
#for x in (1, 2, 3) {
  for _ in range(0, 16) { d.push((x: x, y: 1)) }
}
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-jitter(size: 2pt),),
  width: 10cm,
  height: 6cm,
)

Scatter of overlapping (x, y = 1) rows at x = 1, 2, 3 spread out by jittered position adjustment.

Scatter of overlapping (x, y = 1) rows at x = 1, 2, 3 spread out by jittered position adjustment.

Map fill so each jittered cluster is visually distinct.

#let d = ()
#for grp in ("a", "b", "c") {
  for _ in range(0, 16) { d.push((x: grp, y: 1, grp: grp)) }
}
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", fill: "grp"),
  layers: (geom-jitter(size: 2pt),),
  width: 10cm,
  height: 6cm,
)

Jittered scatter of three discrete x categories (a, b, c) at y = 1 with markers coloured by fill aesthetic.

Jittered scatter of three discrete x categories (a, b, c) at y = 1 with markers coloured by fill aesthetic.

See also

geom-point, position-jitter.

Back to top