Skip to content

Axis

Axis value class for axis configuration.

Ferrum — a statistical visualization library with a Rust core.

Axis dataclass

Per-channel axis configuration.

Parameters:

Name Type Description Default
title str

Axis title text. Pass title=None to suppress the axis title (the field name will not be shown). Omitting title entirely keeps the field-name default.

_UNSET
orient str

Axis orientation ("top", "bottom", "left", "right").

None
ticks bool

Show tick marks.

True
tick_count int

Suggested number of ticks.

None
tick_extra bool

Include extra tick at domain boundary.

False
tick_min_step float

Minimum step between ticks.

None
grid bool

Show grid lines.

True
grid_dash list[float]

Grid line dash pattern.

None
grid_width float

Grid line width.

None
grid_color str

Grid line color.

None
grid_opacity float

Grid line opacity.

None
labels bool

Show tick labels.

True
label_angle float

Tick label rotation angle.

None
label_flush bool

Flush the first and last tick labels against the axis ends so they do not overhang the plot area. Defaults to False (no flush), matching the renderer default.

False
label_overlap str

Label overlap strategy ("greedy", "parity", "rotate"). Defaults to "greedy" (the renderer's graduated collision cascade).

'greedy'
label_format str

d3-format string for labels.

None
label_format_type str

Format type ("number", "time").

None
label_font_size float

Label font size.

None
label_color str

Label color.

None
domain bool

Show axis domain line.

True
domain_width float

Domain line width.

None
domain_color str

Domain line color.

None
offset float

Axis offset from plot area.

None
translate float

Pixel translation.

None
min_band float

Lower bound for the reserved axis margin band, in pixels.

None
max_band float

Upper bound for the reserved axis margin band, in pixels.

.. deprecated:: 0.17.0 min_extent and max_extent are accepted as aliases for min_band and max_band respectively, but are deprecated and will be removed in a future release.

None
title_orient str

Title orientation.

None
title_font_size float

Title font size.

None
title_color str

Title color.

None
title_padding float

Title padding from axis.

None
values list

Explicit tick values.

None
zindex int

Z-index for layering.

None
label_map dict[str, str]

Mapping from original tick-label text to display text. Applied in the Python layer at render time by renaming the corresponding column values in the DataFrame before Rust computes the scale domain. Keys not present in the data are silently ignored.

Example — rename categorical axis labels::

fm.Axis(label_map={"a": "Group A", "b": "Group B"})
None

Examples:

>>> import ferrum as fm
>>> ax = fm.Axis(title="Speed (km/h)", label_angle=-45)
>>> ax.title
'Speed (km/h)'
>>> ax.to_dict()
{'title': 'Speed (km/h)', 'label_angle': -45}

to_dict

to_dict() -> dict[str, Any]

Serialize to dict for the renderer, omitting None, defaults, and Python-only fields.