geom-rect
Rectangle layer drawing one filled box per row from the four corners.
Mapping must provide xmin, xmax, ymin, ymax. Fill resolves via the fill scale or a fixed fill parameter.
Usage
geom-rect(
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. Must map xmin, xmax, ymin, ymax. |
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 or a neutral default. |
stroke |
none |
Outline thickness (a Typst length) or stroke dictionary; none disables the outline and the colour aesthetic. |
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
Three categorical rectangles overlapping along x.
#let d = (
(xmin: 0, xmax: 1, ymin: 0, ymax: 2, k: "a"),
(xmin: 1, xmax: 3, ymin: 1, ymax: 4, k: "b"),
(xmin: 3, xmax: 4, ymin: 2, ymax: 3, k: "a"),
)
#plot(
data: d,
mapping: aes(xmin: "xmin", xmax: "xmax", ymin: "ymin", ymax: "ymax", fill: "k"),
layers: (geom-rect(alpha: 0.6),),
width: 10cm,
height: 6cm,
)A unit-strip swatch lays out a discrete palette horizontally, one rectangle per level.
#let levels = ("a", "b", "c", "d", "e")
#let d = levels.enumerate().map(((i, k)) => (
xmin: i, xmax: i + 1, ymin: 0, ymax: 1, k: k,
))
#plot(
data: d,
mapping: aes(xmin: "xmin", xmax: "xmax", ymin: "ymin", ymax: "ymax", fill: "k"),
layers: (geom-rect(),),
scales: (scale-fill-brewer(palette: "Set1"),),
guides: guides(fill: guide-none()),
width: 8cm,
height: 1cm,
)