ferrum.encoding¶
Encoding channels — declarative mappings from data fields to visual variables.
X ¶
Bases: ChannelBase
Positional X channel — maps a field to the horizontal axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name in the input DataFrame. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type: quantitative, nominal, ordinal, temporal. Inferred from the column dtype when omitted. |
"Q"
|
bin
|
bool or Bin
|
If truthy, bin the field before mapping. Pass a |
required |
aggregate
|
str
|
Aggregation operation applied before mapping (e.g. |
required |
scale
|
Scale
|
Explicit scale override (e.g. |
required |
title
|
str
|
Axis title override. When omitted the field name is used. |
required |
Notes
axis, legend, sort, stack, and impute kwargs are
accepted and forwarded to the EncodingSpec; per-channel axis/legend
customization depends on Rust-side support for the channel.
Examples:
Y ¶
Bases: ChannelBase
Positional Y channel — maps a field to the vertical axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name in the input DataFrame. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type: quantitative, nominal, ordinal, temporal. Inferred from the column dtype when omitted. |
"Q"
|
bin
|
bool or Bin
|
If truthy, bin the field before mapping. Pass a |
required |
aggregate
|
str
|
Aggregation operation applied before mapping (e.g. |
required |
scale
|
Scale
|
Explicit scale override (e.g. |
required |
title
|
str
|
Axis title override. When omitted the field name is used. |
required |
Notes
axis, legend, sort, stack, and impute kwargs are
accepted and forwarded to the EncodingSpec; per-channel axis/legend
customization depends on Rust-side support for the channel.
Examples:
X2 ¶
Bases: ChannelBase
Secondary X channel — maps a field to the second x position.
Used for ranged marks (rule, rect, ribbon) where a mark spans
from x to x2 along the horizontal axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name in the input DataFrame. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
bin, aggregate, scale, and title kwargs are accepted but
are reserved for future use (no-op today) — they trigger a one-time
deprecation warning.
Examples:
Y2 ¶
Bases: ChannelBase
Secondary Y channel — maps a field to the second y position.
Used for ranged marks (rule, rect, ribbon) where a mark spans
from y to y2 along the vertical axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name in the input DataFrame. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
bin, aggregate, scale, and title kwargs are accepted but
are reserved for future use (no-op today) — they trigger a one-time
deprecation warning.
Examples:
XError ¶
Bases: ChannelBase
X-axis error channel — maps a field to symmetric error around x.
The error bar extends x ± x_error along the horizontal axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name whose values are the error magnitude. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
YError ¶
Bases: ChannelBase
Y-axis error channel — maps a field to symmetric error around y.
The error bar extends y ± y_error along the vertical axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name whose values are the error magnitude. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
XError2 ¶
Bases: ChannelBase
Secondary x-axis error channel — for asymmetric error bounds.
When paired with XError, sets the upper bound of the error bar
independently of the lower bound, enabling asymmetric error bars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name whose values are the upper-side error magnitude. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
YError2 ¶
Bases: ChannelBase
Secondary y-axis error channel — for asymmetric error bounds.
When paired with YError, sets the upper bound of the error bar
independently of the lower bound, enabling asymmetric error bars.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name whose values are the upper-side error magnitude. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
Theta ¶
Bases: ChannelBase
Polar angle channel — maps a field to the angular position in polar coords.
Typically used with arc or pie marks; the field values determine the sweep angle of each arc segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name in the input DataFrame. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
stack
|
bool or str
|
Stacking behaviour for arc segments. |
required |
Notes
Requires CoordPolar() on the chart to activate polar rendering;
without it the channel is registered but the mark renders in Cartesian
space.
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
Radius ¶
Bases: ChannelBase
Polar radius channel — maps a field to the radial position in polar coords.
Controls how far each mark is placed from the center of the polar plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name in the input DataFrame. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
Requires CoordPolar() on the chart to activate polar rendering;
without it the channel is registered but the mark renders in Cartesian
space.
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
Color ¶
Bases: ChannelBase
Color encoding channel — maps a field to mark color (fill and stroke).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to map to color. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type: quantitative, nominal, ordinal, temporal. Inferred from the column dtype when omitted. |
"Q"
|
scheme
|
str
|
Named color scheme for categorical data (e.g. |
required |
scale
|
Scale
|
Explicit scale override (e.g. |
required |
title
|
str
|
Legend title override. When omitted the field name is used. |
required |
Notes
legend is honored: passing legend={"disabled": True},
legend=None, or legend=False suppresses the color legend in the
rendered SVG. sort is honored: pass a list of strings to set the
explicit domain order for the color scale. condition is accepted but
reserved for future use.
Examples:
Fill ¶
Bases: ChannelBase
Fill color channel — maps a field to filled-mark fill color.
Distinct from stroke, which controls only the outline color. When
both Fill and Color are encoded, Fill takes precedence for the
interior of the mark.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to map to fill color. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
scale, title, legend, and condition kwargs are accepted
but are reserved for future use (no-op today) — they trigger a one-time
deprecation warning.
Examples:
Stroke ¶
Bases: ChannelBase
Stroke color channel — maps a field to mark stroke (outline) color.
Distinct from fill, which controls only the interior color.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to map to stroke color. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
scale, title, legend, and condition kwargs are accepted
but are reserved for future use (no-op today) — they trigger a one-time
deprecation warning.
Examples:
Opacity ¶
Bases: ChannelBase
Opacity channel — maps a field to overall mark opacity.
Controls both fill and stroke opacity simultaneously. Values are mapped
to the range [0, 1].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to map to opacity. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
scale
|
Scale
|
Explicit scale override. |
required |
title
|
str
|
Legend title override. |
required |
Notes
legend and condition kwargs are accepted but are reserved for
future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
FillOpacity ¶
Bases: ChannelBase
Fill-opacity channel — maps a field to fill opacity.
Independent of stroke opacity; controls only how transparent the interior
of a mark is. Values are mapped to the range [0, 1].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to map to fill opacity. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
scale, title, legend, and condition kwargs are accepted
but are reserved for future use (no-op today) — they trigger a one-time
deprecation warning.
Examples:
StrokeOpacity ¶
Bases: ChannelBase
Stroke-opacity channel — maps a field to stroke opacity.
Independent of fill opacity; controls only how transparent the outline of
a mark is. Values are mapped to the range [0, 1].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to map to stroke opacity. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
scale, title, legend, and condition kwargs are accepted
but are reserved for future use (no-op today) — they trigger a one-time
deprecation warning.
Examples:
StrokeWidth ¶
Bases: ChannelBase
Stroke-width channel — maps a field to stroke width in pixels.
Larger values produce thicker mark outlines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to map to stroke width. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
scale, title, legend, and condition kwargs are accepted
but are reserved for future use (no-op today) — they trigger a one-time
deprecation warning.
Examples:
StrokeDash ¶
Bases: ChannelBase
Stroke-dash channel — maps a field to a dash pattern.
Each level of the field maps to a distinct dash-gap pattern for the mark stroke (e.g. solid, dashed, dotted).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name (typically nominal or ordinal) to map to dash pattern. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
scale, title, legend, and condition kwargs are accepted
but are reserved for future use (no-op today) — they trigger a one-time
deprecation warning.
Examples:
Size ¶
Bases: ChannelBase
Size channel — maps a field to mark size (point area in square pixels).
For point marks the size value corresponds to the area of the mark in square pixels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to map to size. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
scale
|
Scale
|
Explicit scale override. |
required |
title
|
str
|
Legend title override. |
required |
Notes
legend and condition kwargs are accepted but are reserved for
future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
Shape ¶
Bases: ChannelBase
Shape channel — maps a categorical field to point shape.
Supported shapes include "circle", "square", "triangle",
"cross", "diamond", and "star".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name (should be nominal or ordinal) to map to shape. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted; |
"Q"
|
scale
|
Scale
|
Explicit scale override. |
required |
title
|
str
|
Legend title override. |
required |
Notes
legend and condition kwargs are accepted but are reserved for
future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
Angle ¶
Bases: ChannelBase
Angle channel — maps a field to mark rotation in degrees.
Rotates each mark around its center point. A value of 0 is
upright; values increase clockwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to map to rotation angle. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
scale, title, legend, and condition kwargs are accepted
but are reserved for future use (no-op today) — they trigger a one-time
deprecation warning.
Examples:
Text ¶
Bases: ChannelBase
Text channel — maps a field to text-mark content.
Renders each data point's field value as a text label. Primarily used
with the mark_text mark.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name whose values are rendered as text. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
format
|
str
|
Number or date format string (e.g. |
required |
formatType
|
str
|
Format type hint; |
required |
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
Detail ¶
Bases: ChannelBase
Detail channel — adds a field to the encoding without a visual variable.
Groups marks by the levels of the field without mapping those levels to any visual property (color, size, shape, etc.). Useful for drawing one line per group in a line chart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to group by. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
Tooltip ¶
Bases: ChannelBase
Tooltip channel — specifies which fields appear in the hover tooltip.
Accepts one or more field names (as strings or TooltipField helpers)
that are shown when the viewer hovers over a mark in an interactive
renderer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*fields
|
str or TooltipField
|
One or more column names or |
()
|
Notes
type kwarg is accepted but is reserved for future use (no-op today)
— it triggers a one-time deprecation warning.
Examples:
TooltipField ¶
Bases: ChannelBase
Helper for an individual tooltip field with optional title and format.
Used inside Tooltip(*fields) to customise how a single column is
displayed in the hover tooltip. Not used as a top-level encoding channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
title
|
str
|
Custom tooltip label for this field. |
required |
format
|
str
|
Number or date format string (e.g. |
required |
formatType
|
str
|
Format type hint; |
required |
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
Href ¶
Bases: ChannelBase
URL-link channel — maps a field to a clickable URL.
When the chart is rendered in an interactive renderer, marks become
clickable hyperlinks pointing to the URL stored in field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name containing the URL string for each mark. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning. Interactive renderers only; SVG export does not embed hyperlinks.
Examples:
Description ¶
Bases: ChannelBase
Accessibility description channel — maps a field to per-mark alt text.
The description text is used by screen readers and other accessibility tools to describe each individual mark.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name whose values are used as the accessibility description. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
Key ¶
Bases: ChannelBase
Key channel — maps a field to a unique key per mark.
Provides a stable identity for each mark when joining across data updates (e.g. animated transitions or streaming data).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name whose values uniquely identify each mark. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted. |
"Q"
|
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
Url ¶
Bases: ChannelBase
Image URL channel — maps a field to a base64 data URL for mark_image tiles.
Each row provides a data:image/...;base64,<payload> URL that is
placed as an image tile at the position given by the x and y
encodings. Used exclusively with :meth:~ferrum.Chart.mark_image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name containing the base64 data URL for each tile. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted (typically
|
"Q"
|
Examples:
Facet ¶
Bases: ChannelBase
Facet channel — splits a chart into a grid by levels of a field.
Wraps the chart into a faceted layout where each panel shows data for
one level of the facet field. Pass this channel object to
Chart.encode(facet=...).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to facet by. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted; |
"Q"
|
title
|
str
|
Facet panel title override. When omitted the field name is used. |
required |
Notes
columns (number of facets per row) is accepted as a kwarg but is
reserved for future use (no-op today) — it triggers a one-time
deprecation warning. If you need column-wrap control today, use
Chart.facet(ncols=N) directly.
Examples:
FacetRow ¶
Bases: ChannelBase
Facet-row channel — splits a chart into rows by levels of a field.
Pass this channel object to Chart.encode(facet_row=...) to create a
row-faceted layout where each row shows data for one level of the field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to facet rows by. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted; |
"Q"
|
title
|
str
|
Row-facet title override. When omitted the field name is used. |
required |
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples:
FacetCol ¶
Bases: ChannelBase
Facet-column channel — splits a chart into columns by levels of a field.
Pass this channel object to Chart.encode(facet_col=...) to create a
column-faceted layout where each column shows data for one level of the
field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
field
|
str
|
Column name to facet columns by. |
None
|
type_
|
('Q', 'N', 'O', 'T')
|
Data type. Inferred from the column dtype when omitted; |
"Q"
|
title
|
str
|
Column-facet title override. When omitted the field name is used. |
required |
Notes
Other kwargs are accepted but are reserved for future use (no-op today) — they trigger a one-time deprecation warning.
Examples: