Skip to content

Layer

Layer and the layer() helper for explicit layering.

Ferrum — a statistical visualization library with a Rust core.

Layer

Single rendering layer inside a multi-layer Chart.

Most multi-layer charts are built via the + operator on two Chart instances (chart1 + chart2). Direct construction of Layer objects is rarely needed outside of ferrum internals and composite-mark expansion code.

Parameters:

Name Type Description Default
data object

DataFrame or Arrow-compatible object for this layer. When None the layer inherits data from the parent ChartSpec.

None
mark str or MarkSpec

Mark type string (e.g. "point", "line") or a MarkSpec object.

None
name str

Identifier for this layer, used by composite-mark expansion and layer-targeted mark overrides. None for unnamed layers.

None
encoding dict

Mapping of channel names to ChannelBase objects. Defaults to an empty dict when omitted.

None
transforms list

Sequence of transform objects applied to this layer's data before rendering. Defaults to an empty list when omitted.

None
mark_kwargs dict

Extra keyword arguments forwarded to the mark renderer (e.g. {"dx": 5, "opacity": 0.7}).

None

Examples:

>>> from ferrum.layer import Layer
>>> layer = Layer(mark="text", encoding={"x": "x", "y": "y"}, mark_kwargs={"dx": 5})