geom-typst
Text label layer whose label aesthetic is always evaluated as Typst markup.
Sibling of geom-text. Use this when every label string must be interpreted as Typst markup at the call site, without wrapping each column reference in typst.
Usage
geom-typst(
mapping: none,
data: none,
size: 10pt,
colour: auto,
alpha: auto,
anchor: "center",
dx: 0,
dy: 0,
label: none,
stat: "identity",
position: "identity",
inherit-aes: true,
)Parameters
| Parameter | Default | Description |
|---|---|---|
mapping |
none |
Layer-specific aesthetic mapping built with aes. Must map x and y. Map label to a column when each row carries its own label, or pass label: directly to use a single constant value for every row. |
data |
none |
Layer-specific dataset. Falls back to the plot data when none. |
size |
10pt |
Text size (a Typst length). |
colour |
auto |
Fixed text colour. auto inherits the theme ink. Used when no colour mapping is active. |
alpha |
auto |
Text opacity in [0, 1]. auto honours any mapped alpha aesthetic. |
anchor |
"center" |
CeTZ anchor (e.g., "center", "west") controlling placement. |
dx |
0 |
Horizontal offset, as a number (canvas units, 1 = 1cm) or a Typst length. |
dy |
0 |
Vertical offset, as a number (canvas units, 1 = 1cm) or a Typst length. |
label |
none |
Constant label drawn at every row’s (x, y). Accepts a Typst content block ([#math.alpha], [*bold*]) or a markup string ("$alpha$") eval’d as Typst at render time. When none, the label is read from the label aesthetic mapping. |
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
Each row’s label column carries Typst markup that is evaluated in place; no typst() wrapper is needed at the call site.
#let d = (
(x: 1, y: 1, t: "$alpha$"),
(x: 2, y: 2, t: "*bold*"),
(x: 3, y: 3, t: "#emph[italic]"),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y", label: "t"),
layers: (geom-typst(),),
width: 10cm,
height: 6cm,
)Use a constant content block as the label at every row.
#let d = (
(x: 1, y: 1),
(x: 2, y: 2),
(x: 3, y: 3),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-typst(label: [#math.alpha]),),
width: 10cm,
height: 6cm,
)