Skip to content

Structural

Structural view modifiers — BreakAxis, Inset, SecondaryY.

Ferrum — a statistical visualization library with a Rust core.

BreakAxis dataclass

An axis break that omits a region of the scale to skip outlier values.

Parameters:

Name Type Description Default
axis str

Which axis to break: "x" or "y".

required
gap tuple or list

A single (start, end) break region (a tuple or a list of two bounds) or a sequence of (start, end) pairs for multiple breaks. Each bound is either numeric (int/float or a numpy scalar — np.int64, np.float32, ... — data-space) or temporal (str ISO-8601 date/ datetime, datetime.date, datetime.datetime, numpy.datetime64, or pandas.Timestamp) — temporal bounds are coerced to epoch-milliseconds UTC at construction time by ferrum.annotation.coords.temporal_coord_to_epoch_ms, literally the same function the encoding layer applies to temporal scale domains and annotation coordinates, so all three accept the same types (#230-6). A naive (timezone-unaware) string or datetime bound is treated as UTC; a timezone-aware datetime or pandas.Timestamp bound is converted to UTC before its epoch offset is computed — that function's documented naive/aware split. Both bounds of one gap must be the same kind (numeric or temporal); a pair mixing the two raises ValueError. Once coerced, each (start, end) pair must be finite (no NaN/±inf) and correctly ordered (start < end); a malformed, non-finite, reversed, not-a-time (pd.NaT/np.datetime64('NaT')), out-of-range datetime64, or unparseable-string gap raises ValueError at construction time (#92, #230-6) instead of sailing through to a blank or nonsense render. A temporal gap on a non-temporal axis is out-of-domain and warns BreakAxisIneffective at render time rather than refusing at construction.

The stored gap keeps the container type it was given (a tuple of pairs stays a tuple, so a tuple-spelled BreakAxis stays hashable) while each pair is canonicalized to a 2-tuple of coerced floats.

required
break_size float

Visual size of the break indicator in pixels.

12
break_style str

Break indicator style: "slash", "zigzag", "wave", or "gap".

"slash"

Inset dataclass

An inset chart embedded within a parent chart's plot area.

Parameters:

Name Type Description Default
chart Chart

The chart to embed as an inset.

required
bounds tuple

(left, top, right, bottom) boundary coordinates for the inset within the parent plot area. Each coordinate may be a bare float (a normalized [0, 1] fraction of the plot area — the same as NormCoord), NormCoord itself, or PixelCoord (an absolute pixel offset from the plot area's origin, resolved in Rust against the computed plot rect at layout time). Mixed kinds within one bounds tuple are allowed; each entry resolves independently. A normalized entry outside [0, 1], a negative pixel entry, or an empty box (``left

= rightortop >= bottom, compared only within like kinds) raisesValueError`` at construction time.

.. note:: Dated note (2026-09-11, batch H, F-L08-08): earlier revisions of this docstring described a bare float as a data-space coordinate and stated that PixelCoord was unsupported for inset bounds. Neither was ever true of the design this feature shipped from (the 2026-05-24 inset-panels design fixed bounds as normalized-or-pixel, never data-space) — the docstring claim was same-commit authorship drift, and passing fm.px(...) previously raised TypeError as a stopgap rather than being resolved. Both are corrected here: bare floats and NormCoord are normalized fractions, and PixelCoord now resolves correctly.

required
border bool

Draw a border around the inset.

True
border_color str

Border color.

"#999"
border_dash list[float]

Border dash pattern.

None
background str or None

Inset background color; None for transparent.

"#fff"
shadow bool

Apply a drop shadow to the inset.

False
connect_to tuple

Data coordinates (x, y) of the source region in the parent chart that this inset zooms into. Draws a connector from the parent region to the inset when provided.

None
connect_style str

Connector style: "bracket", "lines", or "none".

"lines"

SecondaryY dataclass

A secondary y-axis encoding overlaid on a chart.

chart + SecondaryY(...) desugars to an appended layer on chart: mark mark, y encoding on field (carrying axis/scale), x inherited from the base chart, color literal color, opacity opacity — flagged as an independent-y layer (GH #52). The base chart's own layer(s) are unchanged, so layered_chart + SecondaryY(...) keeps the base layers sharing the left axis while only the appended layer gets its own right axis; adding multiple SecondaryY instances stacks multiple right axes outward. The base chart must carry an x encoding for the secondary layer to inherit — adding SecondaryY to a chart with no x raises ValueError. field is read from the base chart's own table (the desugar performs no data merge), so a field that is not a column of the base data also raises ValueError at + time. mark must name a primitive mark (point, line, bar, area, rule, text, tick, rect) -- a composite mark name (e.g. "boxplot") would otherwise bypass the mark_*() desugar pipeline and reach the renderer as an unknown primitive, so it raises ValueError at + time; use LayerChart(chart, other_chart, resolve={"y": "independent"}) for a composite overlay on a secondary axis instead.

This re-bases the feature onto ferrum's per-layer independent-y subsystem: unlike the original overlay-only renderer, the secondary series now reserves its own right-side margin band (so the plot area narrows to make room for it, rather than the axis overdrawing the plot), gets a real axis (ticks, labels, per-encoding Axis(...) config), and is fully interactive (tooltips, zoom/pan, hit-testing) like any other layer.

Parameters:

Name Type Description Default
field str

Data field to encode on the secondary y axis.

required
mark str

Mark type for the secondary series.

"line"
axis Axis

Per-axis configuration for the secondary y axis.

None
color str

Color for the secondary mark.

None
opacity float

Opacity for the secondary mark.

None
scale Scale

Scale configuration for the secondary y axis.

None