geom-vline
Vertical reference line at one or more x intercepts.
xintercept can be a scalar or an array drawing one line per value. To drive the lines from data instead, bind xintercept (and optionally colour, alpha, linewidth, linetype) through aes and pass data; one line is then drawn per row, with aesthetics resolved per row.
Usage
geom-vline(
mapping: none,
data: none,
xintercept: none,
colour: auto,
stroke: auto,
alpha: auto,
linetype: auto,
inherit-aes: false,
)Parameters
| Parameter | Default | Description |
|---|---|---|
mapping |
none |
Aesthetic mapping built with aes. Bind xintercept to a column to draw a data-driven line per row. |
data |
none |
Layer-specific dataset for the mapped xintercept column, or none. |
xintercept |
none |
Scalar or array of x values at which to draw vertical lines, used when xintercept is not mapped. Values may be numeric or ISO-8601 date/datetime/time strings when a temporal x scale is active. |
colour |
auto |
Line colour. auto inherits the theme ink. |
stroke |
auto |
Line thickness (a Typst length). |
alpha |
auto |
Line opacity in [0, 1]. |
linetype |
auto |
Dash keyword. Defaults to "solid". |
inherit-aes |
false |
Whether to merge the plot-level mapping into this layer’s mapping. Defaults to false. |
Returns
Layer dictionary consumed by plot.
Examples
Two vertical reference lines at x = 3 and x = 6.
#let d = range(0, 10).map(i => (x: i, y: i * 0.5))
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (
geom-point(size: 2pt),
geom-vline(xintercept: (3, 6), colour: rgb("#4c78a8")),
),
width: 10cm,
height: 6cm,
)A single dashed reference line at the data midpoint.
#let d = range(0, 10).map(i => (x: i, y: i * 0.5))
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (
geom-point(size: 2pt),
geom-vline(xintercept: 4.5, stroke: 1pt, colour: rgb("#cc0000")),
),
width: 10cm,
height: 6cm,
)Drive reference lines from data: bind xintercept and colour through aes so each event row draws its own coloured line.
#let d = range(0, 10).map(i => (x: i, y: i * 0.5))
#let events = (
(at: 2, grp: "a"),
(at: 5, grp: "b"),
(at: 8, grp: "a"),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (
geom-point(size: 2pt),
geom-vline(mapping: aes(xintercept: "at", colour: "grp"), data: events),
),
width: 10cm,
height: 6cm,
)