geom-spoke
Spoke layer: one segment from (x, y) along (angle, radius) per row.
angle is a Typst angle (e.g., 45deg) when supplied as a layer parameter; mapped values are read as numbers in radians from the data. radius is the segment length in data units.
Usage
geom-spoke(
mapping: none,
data: none,
angle: 0deg,
radius: 1,
stroke: auto,
colour: auto,
alpha: auto,
linetype: auto,
arrow: none,
stat: "identity",
position: "identity",
key: auto,
inherit-aes: true,
)Parameters
| Parameter | Default | Description |
|---|---|---|
mapping |
none |
Layer-specific aesthetic mapping built with aes. Must map x, y. angle and radius may be mapped or left to the layer-level fallbacks. |
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. |
angle |
0deg |
Layer-level direction (a Typst angle, e.g., 45deg) used when aes(angle: ...) is not mapped. |
radius |
1 |
Layer-level length in data units used when aes(radius: ...) is not mapped. |
stroke |
auto |
Line thickness (a Typst length). |
colour |
auto |
Fixed line colour. auto resolves via the colour scale. |
alpha |
auto |
Line opacity in [0, 1]. |
linetype |
auto |
Dash keyword (e.g., "solid", "dashed"). auto honours the linetype scale. |
arrow |
none |
Arrowhead spec built with arrow, marking the direction each spoke points in. none draws no head. |
stat |
"identity" |
Statistical transform name. Usually "identity". |
position |
"identity" |
Position adjustment name. Usually "identity". |
key |
auto |
Legend glyph override built with a draw-key-* helper. auto picks the default for the geom. |
inherit-aes |
true |
Whether to merge the plot-level mapping into this layer’s mapping. |
Returns
Layer dictionary consumed by plot.
Examples
Eight unit-length spokes radiating from the origin at evenly spaced angles.
#let d = range(0, 8).map(i => (
x: 0, y: 0, angle: i * calc.pi / 4, r: 1,
))
#plot(
data: d,
mapping: aes(x: "x", y: "y", angle: "angle", radius: "r"),
layers: (geom-spoke(stroke: 1pt),),
width: 8cm,
height: 8cm,
)A vector field: an arrow head turns each spoke into the directed segment the geom is named for. The limits leave room past the tips, since a head at the panel edge is clipped with its line.
#let d = range(0, 3).map(i => range(0, 3).map(j => (
x: i, y: j, angle: (i + j) * calc.pi / 5, r: 0.6,
))).flatten()
#plot(
data: d,
mapping: aes(x: "x", y: "y", angle: "angle", radius: "r"),
layers: (geom-spoke(stroke: 1pt, arrow: arrow(length: 6pt)),),
scales: scales(
x: scale-continuous(limits: (-1, 3)),
y: scale-continuous(limits: (-1, 3)),
),
width: 8cm,
height: 8cm,
)