Skip to content

ferrum.axis

Per-channel axis configuration.

The Axis dataclass controls axis appearance — title, ticks, grid lines, labels, domain line, and positioning. Pass an Axis instance to an encoding channel's axis= parameter, or use axis=False to suppress the axis entirely.

Axis dataclass

Per-channel axis configuration.

Parameters:

Name Type Description Default
title str

Axis title text.

None
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 labels at axis boundaries.

True
label_overlap str

Label overlap strategy ("parity", "greedy").

'parity'
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_extent float

Minimum axis extent.

None
max_extent float

Maximum axis extent.

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.