geom-count
Count layer drawing one marker per unique (x, y), sized by frequency.
Usage
geom-count(
mapping: none,
data: none,
size: auto,
stroke: auto,
fill: auto,
colour: auto,
alpha: auto,
shape: auto,
stat: "sum",
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. |
size |
auto |
Marker size (a Typst length). auto honours the size scale, which stat-sum wires to the per-cell count. |
stroke |
auto |
Marker outline thickness (a Typst length) or stroke dictionary; 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 only when neither colour nor fill is set. |
alpha |
auto |
Marker opacity in [0, 1]. |
shape |
auto |
Marker shape keyword. auto honours the shape scale. |
stat |
"sum" |
Statistical transform name. Defaults to "sum". |
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
Marker size grows with the number of duplicate (x, y) rows.
#let d = (
(x: 1, y: 1),
(x: 1, y: 1),
(x: 2, y: 2),
(x: 3, y: 3),
(x: 3, y: 3),
(x: 3, y: 3),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-count(),),
width: 10cm,
height: 6cm,
)Pair with scale-size-area to give markers an area-proportional scaling (instead of a radius-proportional one).
#let d = (
(x: 1, y: 1),
(x: 1, y: 1),
(x: 2, y: 2),
(x: 3, y: 3),
(x: 3, y: 3),
(x: 3, y: 3),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-count(),),
scales: (scale-size-area(range: (1pt, 12pt)),),
width: 10cm,
height: 6cm,
)