Configure¶
Chart-level configuration dataclasses — Configure, AxisConfig, ColorConfig, GridConfig, LegendConfig, PaddingConfig, TitleConfig — plus format-preset resolution (resolve_format) and the Chart.override error (FerrumOverrideError).
Ferrum — a statistical visualization library with a Rust core.
AxisConfig
dataclass
¶
Chart-level axis configuration applied uniformly to all axes (or a specific one).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
bool
|
Deprecated and has no effect. Use |
True
|
y
|
bool
|
Deprecated and has no effect. Use |
True
|
label_angle
|
float
|
Tick label rotation angle in degrees. |
None
|
label_font_size
|
float
|
Tick label font size. |
None
|
label_color
|
str
|
Tick label color. |
None
|
label_format
|
str
|
Named format preset (see |
None
|
label_format_raw
|
str
|
Raw d3-format or strftime string passed directly to the renderer.
Mutually exclusive with |
None
|
label_overlap
|
str
|
Label overlap strategy: |
None
|
tick_count
|
int
|
Suggested number of ticks. |
None
|
tick_size
|
float
|
Tick mark length in pixels. |
None
|
tick_values
|
list
|
Explicit tick values. |
None
|
title_font_size
|
float
|
Axis title font size. |
None
|
title_color
|
str
|
Axis title color. |
None
|
title_padding
|
float
|
Padding between the axis title and tick labels. |
None
|
label_padding
|
float
|
Pixel gap between the tick mark endpoint and the label text baseline. Defaults to 2.0 when not set. |
None
|
domain
|
bool
|
Show the axis domain line. |
None
|
domain_color
|
str
|
Domain line color. |
None
|
domain_width
|
float
|
Domain line width. |
None
|
grid
|
bool
|
Show grid lines. |
None
|
grid_color
|
str
|
Grid line color. |
None
|
grid_dash
|
list[float]
|
Grid line dash pattern. |
None
|
grid_width
|
float
|
Grid line width. |
None
|
domain_min
|
float
|
Minimum value of the scale domain. |
None
|
domain_max
|
float
|
Maximum value of the scale domain. |
None
|
nice
|
bool
|
Round the scale domain to nice round values. |
None
|
zero
|
bool
|
Include zero in the scale domain. |
None
|
grid_opacity
|
float
|
Grid line opacity (0--1). |
None
|
orient
|
str
|
Axis side: |
None
|
translate
|
float
|
Pixel translation of the axis group perpendicular to its line. |
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
|
None
|
tick_extra
|
bool
|
Append an extra tick at each domain boundary. |
None
|
tick_min_step
|
float
|
Minimum step between ticks in data space. |
None
|
title_orient
|
str
|
Side/orientation of the axis title. |
None
|
zindex
|
int
|
Coarse draw order of the axis relative to marks. |
None
|
to_dict ¶
Serialize to dict, omitting None values.
label_format preset names are resolved to their d3-format strings
before serialization so the Rust side receives a ready-to-use format spec.
ColorConfig
dataclass
¶
Chart-level color scale configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scheme
|
str
|
Named color scheme for categorical encodings. |
None
|
sequential_scheme
|
str
|
Named scheme for sequential (single-hue) encodings. |
None
|
diverging_scheme
|
str
|
Named scheme for diverging encodings. |
None
|
domain
|
list
|
Explicit scale domain values. |
None
|
range
|
list[str]
|
Explicit list of color strings for the range. |
None
|
Configure
dataclass
¶
Container for chart-level configuration overrides.
Each field maps to a specific configuration domain. Unset fields
(None) mean "use the chart/theme default" — only fields that are
explicitly set are forwarded to the renderer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
AxisConfig
|
Applies to all axes. |
None
|
axis_x
|
AxisConfig
|
Applies only to the x axis (overrides |
None
|
axis_y
|
AxisConfig
|
Applies only to the y axis (overrides |
None
|
axis_y2
|
AxisConfig
|
Applies only to the secondary y axis. |
None
|
legend
|
LegendConfig
|
Legend appearance. |
None
|
title
|
TitleConfig
|
Chart title appearance. |
None
|
grid
|
GridConfig
|
Grid line appearance. |
None
|
padding
|
PaddingConfig
|
Plot-area padding. |
None
|
color
|
ColorConfig
|
Default color scale settings. |
None
|
to_dict ¶
Serialize to dict, omitting None fields and recursing into sub-configs.
FerrumOverrideError ¶
Bases: Exception
Raised when a :meth:ferrum.Chart.override path cannot be resolved.
Chart.override(**kwargs) is a flat snake_case escape hatch onto the
chart's presentation spec. Because the Rust spec deserializers silently
drop unknown fields, a misspelled or unsupported path would otherwise be a
silent no-op. Override paths are therefore validated Python-side against a
registry generated from the live schemas; any path that does not resolve
(unknown prefix, or a known prefix with a leaf that is not a valid field of
its target) raises this error at render time, naming the offending path and
— when a close match exists — suggesting the nearest valid path.
Examples:
GridConfig
dataclass
¶
Chart-level grid configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
bool
|
Show x-axis grid lines. |
None
|
y
|
bool
|
Show y-axis grid lines. |
None
|
color
|
str
|
Grid line color. |
None
|
width
|
float
|
Grid line width. |
None
|
dash
|
list[float]
|
Grid line dash pattern. |
None
|
opacity
|
float
|
Grid line opacity. |
None
|
band_colors
|
list[str]
|
Alternating band fill colors between grid lines. |
None
|
LegendConfig
dataclass
¶
Chart-level legend configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orient
|
str
|
Legend position: |
None
|
direction
|
str
|
Layout direction: |
None
|
columns
|
int
|
Number of columns for multi-column layout. |
None
|
title_font_size
|
float
|
Legend title font size. |
None
|
label_font_size
|
float
|
Legend label font size. |
None
|
label_color
|
str
|
Legend label color. |
None
|
label_limit
|
float
|
Maximum legend-label width in pixels; wider labels are truncated with an ellipsis. |
None
|
symbol_size
|
float
|
Symbol size. |
None
|
symbol_stroke_width
|
float
|
Stroke width of legend symbol swatches in pixels. |
None
|
symbol_type
|
str
|
Symbol shape type. |
None
|
gradient_length
|
float
|
Gradient legend length. |
None
|
gradient_thickness
|
float
|
Gradient legend thickness in pixels. |
None
|
title_padding
|
float
|
Padding between the legend title and its entries. |
None
|
row_padding
|
float
|
Vertical entry spacing in pixels (vertical-direction legends). |
None
|
column_padding
|
float
|
Horizontal entry spacing in pixels (horizontal-direction legends). |
None
|
clip_height
|
float
|
Cap on the legend group height in pixels; overflow is hard-clipped. |
None
|
tick_min_step
|
float
|
Minimum step between colorbar ticks in data units. |
None
|
offset
|
float
|
Offset from the plot area. |
None
|
padding
|
float
|
Internal padding. |
None
|
zindex
|
int
|
Coarse draw order of the legend relative to marks. |
None
|
PaddingConfig
dataclass
¶
Chart-level padding configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
top
|
float
|
Top padding in pixels. |
None
|
right
|
float
|
Right padding in pixels. |
None
|
bottom
|
float
|
Bottom padding in pixels. |
None
|
left
|
float
|
Left padding in pixels. |
None
|
auto
|
bool
|
When True and all four sides are None, let the renderer choose padding automatically. |
True
|
TitleConfig
dataclass
¶
Chart-level title configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
font_size
|
float
|
Title font size. |
None
|
font_weight
|
str
|
Title font weight (e.g. |
None
|
anchor
|
str
|
Horizontal anchor: |
None
|
color
|
str
|
Title color. |
None
|
offset
|
float
|
Pixel offset from the plot area. |
None
|
subtitle_font_size
|
float
|
Subtitle font size. |
None
|
subtitle_color
|
str
|
Subtitle color. |
None
|
resolve_format ¶
Resolve a named preset to its d3-format or strftime string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A key from |
required |
Returns:
| Type | Description |
|---|---|
str
|
The corresponding format string. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If name is not a recognized preset key. |
Examples: