geom-mark
Annotation layer enclosing each group with a chosen shape.
Splits rows by group (via colour/fill/group aesthetic), then draws one shape per group around its (x, y) points. Use to highlight clusters, regions, or category groupings.
Usage
geom-mark(
mapping: none,
data: none,
method: "circle",
expand: 0pt,
n: 64,
colour: auto,
fill: auto,
stroke: 0.5pt,
alpha: auto,
stat: "identity",
position: "identity",
inherit-aes: true,
)Parameters
| Parameter | Default | Description |
|---|---|---|
mapping |
none |
Layer-specific aesthetic mapping built with aes. Must map x, y. Use colour, fill, or group to split rows into separate marks. |
data |
none |
Layer-specific dataset. Falls back to the plot data when none. |
method |
"circle" |
Shape to draw: "rect" (bounding box), "circle" (smallest enclosing circle), "ellipse" (axis-aligned ellipse over the bounding box), or "hull" (convex hull). Named method to avoid clash with the shape aesthetic on geom-point. |
expand |
0pt |
Canvas-space padding around each shape, as a Typst length (e.g., 5pt, 0.5cm). 0pt draws the shape flush with the cluster. |
n |
64 |
Polygon resolution for "circle" and "ellipse". |
colour |
auto |
Fixed outline colour. auto resolves via the colour scale. |
fill |
auto |
Fixed fill colour. auto resolves via the fill scale. |
stroke |
0.5pt |
Outline thickness (a Typst length) or stroke dictionary; none disables the outline. |
alpha |
auto |
Fill opacity in [0, 1]. |
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
Hull-marking three clusters with translucent fill.
#let pts = ()
#for (cx, cy, k) in ((1, 1, "a"), (4, 1, "b"), (2.5, 4, "c")) {
for i in range(0, 8) {
pts.push((
x: cx + 0.6 * calc.cos(i * 0.7),
y: cy + 0.6 * calc.sin(i * 0.7),
k: k,
))
}
}
#plot(
data: pts,
mapping: aes(x: "x", y: "y", fill: "k"),
layers: (
geom-mark(method: "hull", expand: 5pt, alpha: 0.3),
geom-point(size: 3pt),
),
width: 10cm,
height: 6cm,
)