geom-curve
Curved segment layer: one quadratic bezier from (x, y) to (xend, yend) per row.
curvature chooses the magnitude and side of the bow:
0collapses to a straightgeom-segment.- Positive values curve to the right of the chord (looking from start to end).
- Negative values curve to the left.
angle shifts the control point along the chord (in addition to the perpendicular offset), producing asymmetric arcs. 90deg gives a symmetric bow; smaller or larger angles bias the apex toward one end.
Usage
geom-curve(
mapping: none,
data: none,
curvature: 0.5,
angle: 90deg,
n: 32,
stroke: 0.8pt,
colour: auto,
alpha: auto,
linetype: "solid",
stat: "identity",
position: "identity",
inherit-aes: true,
)Parameters
| Parameter | Default | Description |
|---|---|---|
mapping |
none |
Layer-specific aesthetic mapping built with aes. Must map x, y, xend, yend. |
data |
none |
Layer-specific dataset. Falls back to the plot data when none. |
curvature |
0.5 |
Bezier-control offset as a fraction of the chord length. 0 draws a straight segment; sign flips the side of the bow. |
angle |
90deg |
Apex angle in (0deg, 180deg). 90deg is symmetric. |
n |
32 |
Number of polyline samples along the curve. |
stroke |
0.8pt |
Line thickness (a Typst length). |
colour |
auto |
Fixed line colour. auto resolves via the colour scale. |
alpha |
auto |
Line opacity in [0, 1]. |
linetype |
"solid" |
Dash keyword. Defaults to "solid". |
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
Three curved connectors with the default symmetric bow.
#let d = (
(x: 0, y: 0, xend: 4, yend: 3, k: "a"),
(x: 0, y: 3, xend: 4, yend: 0, k: "b"),
(x: 2, y: 0, xend: 2, yend: 3, k: "a"),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y", xend: "xend", yend: "yend", colour: "k"),
layers: (geom-curve(curvature: 0.5, stroke: 1pt),),
width: 10cm,
height: 6cm,
)Negative curvature flips the arc to the other side.
#let d = ((x: 0, y: 0, xend: 4, yend: 3),)
#plot(
data: d,
mapping: aes(x: "x", y: "y", xend: "xend", yend: "yend"),
layers: (geom-curve(curvature: -0.5, stroke: 1pt),),
width: 10cm,
height: 6cm,
)