geom-area
Area layer: filled polygon from y = 0 up to y along x, per group.
Mapping must provide x and y. Discrete colour, fill, or group mappings split rows into separate filled polygons drawn back to front.
Usage
geom-area(
mapping: none,
data: none,
colour: auto,
fill: auto,
stroke: none,
alpha: auto,
stat: "identity",
position: "identity",
inherit-aes: true,
)Parameters
| Parameter | Default | Description |
|---|---|---|
mapping |
none |
Layer-specific aesthetic mapping built with aes. Falls back to the plot mapping when none. |
data |
none |
Layer-specific dataset. Falls back to the plot data when none. |
colour |
auto |
Fixed outline colour. auto resolves via the colour scale, falling back to the theme ink only when neither colour nor fill is set. |
fill |
auto |
Fixed fill colour. auto resolves via the fill scale, the colour scale, or a neutral default. |
stroke |
none |
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
Single filled area between y = 0 and a smooth curve.
#let d = range(0, 12).map(i => (x: i, y: calc.sin(i * 0.6) + 1.5))
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-area(alpha: 0.4),),
width: 10cm,
height: 6cm,
)Map fill to a discrete column to draw one polygon per group; position: "stack" accumulates them.
#let d = ()
#for grp in ("a", "b") {
for i in range(0, 12) {
d.push((x: i, y: 0.5 + calc.sin(i * 0.5) + (if grp == "b" { 1 } else { 0 }), grp: grp))
}
}
#plot(
data: d,
mapping: aes(x: "x", y: "y", fill: "grp"),
layers: (geom-area(position: "stack", alpha: 0.6),),
width: 10cm,
height: 6cm,
)