Skip to content

Encoding

Typed encoding channels — X, Y, Color, Size, Tooltip, and more.

Ferrum — a statistical visualization library with a Rust core.

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

condition is honored: pass a ConditionalSpec built via sel.when(...).otherwise(...) (or fm.when(sel).then(...).otherwise(...)) to switch rotation based on selection state -- see Chart.encode()'s condition= translation (ferrum-spec.md §3.10).

Angle draws no legend of its own. legend=None/legend=False are accepted silently; title= and a legend dict/Legend(...) raise ValueError at construction, since there is nothing for them to label.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="x", y="y", angle=fm.Angle("direction"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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 categorical color scheme (e.g. "tableau10", "set1").

required
scale Scale

Explicit scale override (e.g. fm.ContinuousScheme("viridis") or fm.continuous_palette("viridis")).

required
title str

Legend title override. When omitted the field name is used.

required
bin (bool, dict or Bin)

Color by bins of the numeric field: True for the Bin transform's default edges, or a dict or fm.Bin(...) of bin_count, bin_width, extent and nice. The rows are kept, each colored by its bin, the legend lists the bin ranges, and a statistic grouped by this channel groups by bin. Refused together with scale=, aggregate=, a nominal or temporal type_= or a sort= other than ascending, and for a Bin declaring a statistic, a grouping or a name.

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 honored: pass a ConditionalSpec built via sel.when(...).otherwise(...) (or fm.when(sel).then(...).otherwise(...)) to switch color based on selection state -- see Chart.encode()'s condition= translation (ferrum-spec.md §3.10).

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg", color=fm.Color("cyl"))
>>> fm.Chart(df).encode(x="hp", y="mpg", color=fm.Color("origin", scheme="set1"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="x", y="y", description=fm.Description("alt_text"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="year", y="value", detail=fm.Detail("series"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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; "N" or "O" are the most common choices.

"Q"
title str

Facet strip title. When set, the strip text renders "{title}: {value}"; when omitted, the strip shows the bare value (not the field name).

required
columns int

Maximum number of panels per row (wrap-count). Writes the same sink as Chart.facet(ncols=N); when both are used, whichever is called last wins. None lets the renderer choose.

required
sort optional

Panel order — the same sort vocabulary the positional channels accept: "ascending"/"descending", an explicit list of values, or a sort-field object ({"field": ..., "op": ..., "order": ...}) ordering by another field's aggregate. A sort object without a string "field", or with an unrecognized "op"/"order", raises ValueError at construction naming Facet(sort=...) and the value.

required

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg", facet=fm.Facet("species")).mark_point()
>>> fm.Chart(df).encode(x="hp", y="mpg", facet=fm.Facet("species", columns=3)).mark_point()
>>> fm.Chart(df).encode(x="hp", y="mpg").mark_point().facet("species", ncols=3)

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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; "N" or "O" are the most common choices.

"Q"
title str

Column/wrap-strip title. When set, the strip text renders "{title}: {value}"; when omitted, the strip shows the bare value (not the field name).

required
sort optional

Column order — same vocabulary and construction-time validation as Facet(sort=...); ordered on the column/wrap strip.

required
Notes

columns is not honored (2026-09-23, #123): row/column faceting has no wrap-count to apply it to, so FacetCol(field, columns=N) raises ValueError at construction naming Facet(columns=...) for wrap-mode panel-per-row counts instead.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg", facet_col=fm.FacetCol("species")).mark_point()

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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; "N" or "O" are the most common choices.

"Q"
title str

Row-strip title. When set, the strip text renders "{title}: {value}"; when omitted, the strip shows the bare value (not the field name). NOTE: FacetRow used alone (no facet_col) lowers to a wrap-mode facet where the wrap/column strip is the one rendered, so title here drives THAT strip; in grid mode (used together with facet_col), title drives the row-header strip.

required
sort optional

Row order — same vocabulary and construction-time validation as Facet(sort=...); ordered by the same strip title follows (the wrap/column strip alone, or the row-header strip in grid mode).

required
Notes

columns is not honored (2026-09-23, #123): row/column faceting has no wrap-count to apply it to, so FacetRow(field, columns=N) raises ValueError at construction naming Facet(columns=...) for wrap-mode panel-per-row counts instead.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg", facet_row=fm.FacetRow("year")).mark_point()

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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, Color decides the interior of the mark and the Fill encoding is dropped without a warning.

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"
scheme str

Named categorical or continuous color scheme (e.g. "tableau10", "viridis"), validated against the palette registry.

required
scale Scale

Explicit scale override (e.g. fm.ContinuousScheme("viridis")).

required
title str

Legend title override. When omitted the field name is used.

required
bin (bool, dict or Bin)

Color by bins of the numeric field: True for the Bin transform's default edges, or a dict or fm.Bin(...) of bin_count, bin_width, extent and nice. The rows are kept, each colored by its bin, the legend lists the bin ranges, and a statistic grouped by this channel groups by bin. Refused together with scale=, aggregate=, a nominal or temporal type_= or a sort= other than ascending, and for a Bin declaring a statistic, a grouping or a name.

required
Notes

legend is honored: passing legend={"disabled": True}, legend=None, or legend=False suppresses the fill legend in the rendered SVG. condition is honored: pass a ConditionalSpec built via sel.when(...).otherwise(...) (or fm.when(sel).then(...).otherwise(...)) to switch fill based on selection state -- see Chart.encode()'s condition= translation (ferrum-spec.md §3.10). The conditional lands on the color channel, the same target fill aliases to for its base encoding, so encode(fill=fm.Fill("c", condition=cond)) and encode(fill=cond) produce the identical wire conditional.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg", fill=fm.Fill("origin"))
>>> fm.Chart(df).encode(x="hp", y="mpg", fill=fm.Fill("origin", scheme="set1"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"
scale LinearScale, LogScale, PowScale, SqrtScale, or dict

Explicit scale override: domain sets the data extent and range the alphas it maps onto, each endpoint clamped to [0, 1]. domain, range and reverse are honored on every kind; nice and zero only on LinearScale, its own fields. A value outside the domain clamps to the nearer end of the range on every kind -- this channel always clamps, where a positional axis defaults to not clamping. Under LogScale, a value on the far side of zero from the domain is not drawn, as on a positional axis, and the chart warns naming the row count. Any other scale type, padding, scheme, or a domain or range whose length is not 2 raises ValueError at construction.

required
title str

Legend title override. When omitted the field name is used.

required
Notes

condition is honored: pass a ConditionalSpec built via sel.when(...).otherwise(...) (or fm.when(sel).then(...).otherwise(...)) to switch fill opacity based on selection state -- see Chart.encode()'s condition= translation (ferrum-spec.md §3.10).

legend is honored: a field bound to fill opacity draws a legend of swatches at round values of the domain, each drawn at the alpha the scale maps it to. legend=None or legend=False suppresses it and keeps the mapped alphas; legend=Legend(title=..., format=...) customizes it. The legend is an auxiliary block that shares the chart's legend position, so a legend= value whose orient= is anything other than "none" is refused.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg", fill_opacity=fm.FillOpacity("density"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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

Interactive renderers only; SVG export does not embed hyperlinks.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="x", y="y", href=fm.Href("url"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="x", y="y", key=fm.Key("id"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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 LinearScale, LogScale, PowScale, SqrtScale, or dict

Explicit scale override: domain sets the data extent and range the alphas it maps onto, each endpoint clamped to [0, 1]. domain, range and reverse are honored on every kind; nice and zero only on LinearScale, its own fields. A value outside the domain clamps to the nearer end of the range on every kind -- this channel always clamps, where a positional axis defaults to not clamping. Under LogScale, a value on the far side of zero from the domain is not drawn, as on a positional axis, and the chart warns naming the row count. Any other scale type, padding, scheme, or a domain or range whose length is not 2 raises ValueError at construction.

required
title str

Legend title override. When omitted the field name is used.

required
Notes

condition is honored: pass a ConditionalSpec built via sel.when(...).otherwise(...) (or fm.when(sel).then(...).otherwise(...)) to switch opacity based on selection state -- see Chart.encode()'s condition= translation (ferrum-spec.md §3.10).

legend is honored: a field bound to opacity draws a legend of swatches at round values of the domain, each drawn at the alpha the scale maps it to. legend=None or legend=False suppresses it and keeps the mapped alphas; legend=Legend(title=..., format=...) customizes it. The legend is an auxiliary block that shares the chart's legend position, so a legend= value whose orient= is anything other than "none" is refused.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg", opacity=fm.Opacity("year"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"
stack bool or str

Stacking behaviour for radial bars (wind-rose / coxcomb charts). True or "zero" accumulates segments outward from the origin; "normalize" produces percentage rings; "center" produces a symmetric streamgraph-style layout. False or None disables stacking. Requires mark_bar under CoordPolar.

required
aggregate str

Aggregation operation applied before mapping (e.g. "mean"): radius="mean(z)" draws each group's mean as its radius.

required
Notes

Requires CoordPolar() on the chart to activate polar rendering; without it the channel is registered but the mark renders in Cartesian space.

When stack is set, the radius channel is remapped to y (the value axis) before reaching Rust's apply_stack; bar.rs build_polar then reads __stack_y_base__ as the inner radius so each segment starts where the previous one ended. Pass position=fm.Stack() on mark_bar() as an alternative.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(theta=fm.Theta("count"), radius=fm.Radius("distance"))
>>> # Stacked wind-rose / coxcomb:
>>> fm.Chart(df).encode(
...     theta=fm.Theta("direction"),
...     radius=fm.Radius("speed", stack=True),
...     color="category:N",
... ).coord(fm.CoordPolar(theta="x"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

Radius2

Bases: ChannelBase

Polar second-extent radius channel — maps a field to the outer radial boundary.

Used with Radius to define an explicit inner/outer radial span for each arc segment (annular wedge marks). When both radius and radius2 are encoded, the arc spans from the radius column value (inner boundary) to the radius2 column value (outer boundary) per row.

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"
aggregate str

Aggregation operation applied before mapping (e.g. "max"). It is one more op in the chart's (or layer's) one aggregate, grouped like radius: radius="min(v)", radius2="max(v)" draws one span per group.

required
Notes

Requires CoordPolar() on the chart to activate polar rendering. Remapped to y2 (when CoordPolar(theta="x")) or x2 (when CoordPolar(theta="y")) before the spec reaches Rust.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(
...     theta=fm.Theta("t_start"),
...     theta2=fm.Theta2("t_end"),
...     radius=fm.Radius("r_inner"),
...     radius2=fm.Radius2("r_outer"),
... )

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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; "N" is the most common choice.

"Q"
scale Scale

Explicit scale override. domain reorders the category-to-glyph assignment, mirroring Color. range picks the glyphs directly: a list of point-shape names ("square", "cross", "diamond", "triangle-up", "triangle-down", "|", "-", ...; see ferrum.marks.base._VALID_POINT_SHAPES for the exact vocabulary) parsed all-or-nothing -- an unrecognized entry raises ValueError naming Shape(scale=...) at construction, and a hand-built spec that reaches Rust with the same problem raises a typed RenderError at render (2026-09-23, #123).

required
title str

Legend title override.

required
Notes

legend is honored: passing legend=None or legend=False suppresses the shape legend in the rendered SVG. legend=Legend(title=..., format=...) customizes the legend title. When legend is omitted, a categorical shape legend is rendered automatically showing one glyph per distinct category value. A legend= value whose orient= is anything other than "none" is refused (2026-09-23, #123): Shape's legend is an auxiliary block that always shares the chart's legend position -- place it with Color(legend=Legend(orient=...)) or configure_legend(orient=...). sort is honored: pass "ascending", "descending", a list of strings for an explicit domain order, or a channel shorthand such as "-y" to sort by the per-category aggregate of another channel.

condition is not honored: shape is not a conditional target, and encode(shape=<ConditionalSpec>) / Shape(field, condition=...) raise ValueError at encode() time naming the channels that are. The wire has a shape channel name but no shape value: a shape conditional could only carry a field reference, which the runtime applies as a no-op, so it would serialize cleanly and then do nothing. An earlier version of this docstring said condition was honored, written on the assumption that reaching the wire meant working; it did not. Refusing beats a kwarg that quietly does nothing. Filed follow-up: EncodingValue::Shape in Rust, after which this channel can honor condition for real.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg", shape=fm.Shape("origin", type_="N"))
>>> fm.Chart(df).encode(x="hp", y="mpg", shape=fm.Shape("origin", sort="descending"))
>>> fm.Chart(df).encode(x="hp", y="mpg", shape=fm.Shape("origin", legend=None))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

Size

Bases: ChannelBase

Size channel — maps a field to a point's area or a line's width.

The size scale maps each value to an area in square pixels. A point mark draws that area. A line mark draws the diameter of a dot with that area, 2 * sqrt(area / pi) pixels, at each vertex, so the line tapers along its length and a line and a point sharing one size encoding agree: the line is as wide as the dot drawn for the same value. A line that binds size cannot also bind stroke_width; rendering such a line raises ValueError.

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 LinearScale, LogScale, PowScale, SqrtScale, or dict

Explicit scale override. Its range is in area units (square pixels) for every mark, a line included; an endpoint below 0 draws as 0. domain, range and reverse are honored on every kind; nice and zero only on LinearScale, its own fields. A value outside the domain clamps to the nearer end of the range on every kind -- size always clamps, where a positional axis defaults to not clamping. Under LogScale, a value on the far side of zero from the domain is not drawn, as on a positional axis, and the chart warns naming the row count. Any other scale type, padding, scheme, or a domain or range whose length is not 2 raises ValueError at construction.

required
title str

Legend title override.

required
Notes

legend is honored: passing legend=None or legend=False suppresses the size legend in the rendered SVG. legend=Legend(title=..., format=...) customizes the legend title and numeric format string. When legend is omitted, a graduated size legend is rendered automatically showing ~5 round representative values from the field's domain. condition is honored: pass a ConditionalSpec built via sel.when(...).otherwise(...) (or fm.when(sel).then(...).otherwise(...)) to switch size based on selection state -- see Chart.encode()'s condition= translation (ferrum-spec.md §3.10). On a line, a conditional size draws the base width in static output; in the interactive view each vertex redraws at the dot-diameter width of its row's active branch. Every branch must be positive on such a line, and a conditional size plus stroke_width raises ValueError as any other size does.

A field size and a conditional size follow one rule under chart + chart: each reaches only the layers of the chart it was declared on. point.encode(size="v") + line sizes the points and leaves the line untapered, and a point beside a line that declared one is not resized by it; the panel still draws one size scale and legend over every layer that draws size. To size both, declare it on the composition: (point + line).encode(size="v"). A size declared on a layered chart as a whole, on a composite such as mark_line(point=True), or on the host of Chart.layer() reaches every layer of that chart that binds none, lines included; one declared on a Layer's own encoding reaches that layer only.

When size and color are both mapped to the same field, ferrum merges them into a single combined legend block.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg", size=fm.Size("weight"))
>>> fm.Chart(df).encode(x="hp", y="mpg", size=fm.Size("pop", legend=None))
>>> fm.Chart(df).mark_line().encode(x="year", y="price", size=fm.Size("volume"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"
scheme str

Named categorical or continuous color scheme (e.g. "tableau10", "viridis"), validated against the palette registry.

required
scale Scale

Explicit scale override (e.g. fm.ContinuousScheme("viridis")).

required
title str

Legend title override. When omitted the field name is used.

required
bin (bool, dict or Bin)

Color by bins of the numeric field: True for the Bin transform's default edges, or a dict or fm.Bin(...) of bin_count, bin_width, extent and nice. The rows are kept, each colored by its bin, the legend lists the bin ranges, and a statistic grouped by this channel groups by bin. Refused together with scale=, aggregate=, a nominal or temporal type_= or a sort= other than ascending, and for a Bin declaring a statistic, a grouping or a name.

required
Notes

legend is honored: passing legend={"disabled": True}, legend=None, or legend=False suppresses the stroke legend in the rendered SVG.

condition is not honored: stroke is not a conditional target, and encode(stroke=<ConditionalSpec>) / Stroke(field, condition=...) raise ValueError at encode() time naming the channels that are. The reason is a missing renderer capability rather than a policy choice: a conditional's only colour value is EncodingValue::Color, which the WASM runtime applies to the mark's fill (apply_value_common; FillStrokeView has no stroke-colour member), so carrying a stroke conditional onto color -- the channel stroke aliases to for its base encoding -- would recolour the interior instead of the outline. Refusing beats silently changing the wrong property. Fill is unaffected and does honor condition (Color is the fill). Filed follow-up: EncodingValue::StrokeColor in Rust, after which this channel can honor condition for real.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg", stroke=fm.Stroke("origin"))
>>> fm.Chart(df).encode(x="hp", y="mpg", stroke=fm.Stroke("origin", scheme="set1"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"
scale Scale

Explicit scale override. domain reorders the category-to-dash assignment, mirroring Shape. range is not honored: the StrokeDash categorical scale's range is a fixed set of palette patterns, which cannot carry an arbitrary domain-to-range mapping, so a range key raises ValueError at construction naming the fixed palette.

required
title str

Legend title override.

required
Notes

legend is honored: passing legend=None or legend=False suppresses the legend in the rendered SVG. scale (explicit scale override, domain only -- see above) and title (legend title) are also honored. A legend= value whose orient= is anything other than "none" is refused (2026-09-23, #123): StrokeDash's legend is an auxiliary block that always shares the chart's legend position -- place it with Color(legend=Legend(orient=...)) or configure_legend(orient=...). sort is honored: pass "ascending", "descending", a list of strings for an explicit domain order, or a channel shorthand such as "-y" to sort by the per-category aggregate of another channel — mirroring Shape, since the Rust build_stroke_dash_scale domain builder already reads it. condition is honored: pass a ConditionalSpec built via sel.when(...).otherwise(...) (or fm.when(sel).then(...).otherwise(...)) to switch stroke dash based on selection state -- see Chart.encode()'s condition= translation (ferrum-spec.md §3.10).

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="x", y="y", stroke_dash=fm.StrokeDash("group", type_="N"))
>>> fm.Chart(df).encode(x="x", y="y", stroke_dash=fm.StrokeDash("group", sort="descending"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"
scale LinearScale, LogScale, PowScale, SqrtScale, or dict

Explicit scale override: domain sets the data extent and range the alphas it maps onto, each endpoint clamped to [0, 1]. domain, range and reverse are honored on every kind; nice and zero only on LinearScale, its own fields. A value outside the domain clamps to the nearer end of the range on every kind -- this channel always clamps, where a positional axis defaults to not clamping. Under LogScale, a value on the far side of zero from the domain is not drawn, as on a positional axis, and the chart warns naming the row count. Any other scale type, padding, scheme, or a domain or range whose length is not 2 raises ValueError at construction.

required
title str

Legend title override. When omitted the field name is used.

required
Notes

condition is honored: pass a ConditionalSpec built via sel.when(...).otherwise(...) (or fm.when(sel).then(...).otherwise(...)) to switch stroke opacity based on selection state -- see Chart.encode()'s condition= translation (ferrum-spec.md §3.10).

legend is honored: a field bound to stroke opacity draws a legend of swatches at round values of the domain, each drawn at the alpha the scale maps it to. legend=None or legend=False suppresses it and keeps the mapped alphas; legend=Legend(title=..., format=...) customizes it. The legend is an auxiliary block that shares the chart's legend position, so a legend= value whose orient= is anything other than "none" is refused.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg", stroke_opacity=fm.StrokeOpacity("year"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

StrokeWidth

Bases: ChannelBase

Stroke-width channel — maps a field to stroke width in pixels.

A linear scale maps the field's extent onto a 1 to 4 pixel band, so larger values draw thicker strokes; values outside an explicit domain draw at the nearer end of the range, and a null value draws the mark's default width. To draw a column of literal pixel widths, pass a scale whose domain equals its range, e.g. StrokeWidth("w", scale=fm.LinearScale(domain=[1, 6], range=[1, 6])).

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"
scale LinearScale, LogScale, PowScale, SqrtScale, or dict

Explicit scale override: domain sets the data extent and range the pixel widths it maps onto; an endpoint below 0 draws as 0. domain, range and reverse are honored on every kind; nice and zero only on LinearScale, its own fields. A value outside the domain clamps to the nearer end of the range on every kind -- stroke width always clamps, where a positional axis defaults to not clamping. Under LogScale, a value on the far side of zero from the domain is not drawn, as on a positional axis, and the chart warns naming the row count. Any other scale type, padding, scheme, or a domain or range whose length is not 2 raises ValueError at construction.

required
title str

Legend title override. When omitted the field name is used.

required
Notes

condition is honored: pass a ConditionalSpec built via sel.when(...).otherwise(...) (or fm.when(sel).then(...).otherwise(...)) to switch stroke width based on selection state -- see Chart.encode()'s condition= translation (ferrum-spec.md §3.10).

legend is honored: a field bound to stroke width draws a legend of line swatches at round values of the domain, each drawn at the width the scale maps it to. legend=None or legend=False suppresses it and keeps the mapped widths; legend=Legend(title=..., format=...) customizes it. The legend is an auxiliary block that shares the chart's legend position, so a legend= value whose orient= is anything other than "none" is refused.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="x", y="y", stroke_width=fm.StrokeWidth("importance"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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. ".2f" for two decimal places, "%b %Y" for abbreviated month and year).

required
format_type str

Format type hint; "number" or "time". Used in combination with format. formatType is accepted as a Vega-compat alias and normalizes to the same wire key.

required

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="x", y="y", text=fm.Text("label"))
>>> fm.Chart(df).encode(x="x", y="y", text=fm.Text("value", format=".1f"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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. True enables stacking; False disables it; "normalize" produces percentage arcs.

required
aggregate str

Aggregation operation applied before mapping (e.g. "sum"): theta="sum(z)", color="g" draws one arc per g.

required
Notes

Requires CoordPolar() on the chart to activate polar rendering; without it the channel is registered but the mark renders in Cartesian space.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(theta=fm.Theta("count", stack=True))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

Theta2

Bases: ChannelBase

Polar second-extent angle channel — maps a field to the angular end position.

Used with Theta to define an explicit angular span for each arc segment (annular wedge marks). When both theta and theta2 are encoded, the arc sweeps from the theta value to the theta2 value directly from data, rather than computing a proportional sweep from column sums.

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"
aggregate str

Aggregation operation applied before mapping (e.g. "max"). It is one more op in the chart's (or layer's) one aggregate, grouped like theta: theta="min(v)", theta2="max(v)" draws one span per group.

required
Notes

Requires CoordPolar() on the chart to activate polar rendering. Remapped to x2 (when CoordPolar(theta="x")) or y2 (when CoordPolar(theta="y")) before the spec reaches Rust.

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(
...     theta=fm.Theta("t_start"),
...     theta2=fm.Theta2("t_end"),
...     radius=fm.Radius("r_inner"),
...     radius2=fm.Radius2("r_outer"),
... )

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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 TooltipField(...) instances to include in the tooltip. Passing a single string is equivalent to Tooltip(TooltipField(field)).

()

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg",
...     tooltip=fm.Tooltip("hp", "mpg"))
>>> fm.Chart(df).encode(x="hp", y="mpg",
...     tooltip=fm.Tooltip("hp", fm.TooltipField("cyl", title="Cylinders")))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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. ".1f", "%Y-%m-%d").

required
format_type str

Format type hint; "number" or "time". formatType is accepted as a Vega-compat alias and normalizes to the same wire key.

required

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="hp", y="mpg",
...     tooltip=fm.Tooltip("hp", fm.TooltipField("mpg", title="MPG", format=".1f")))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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 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 "N" for string columns).

"Q"

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).mark_image().encode(x="x:Q", y="y:Q", url=fm.Url("data_url"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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 Bin(...) instance to control bin width or count; True uses automatic binning.

required
aggregate str

Aggregation operation applied before mapping (e.g. "mean", "sum", "count").

required
scale Scale

Explicit scale override (e.g. LogScale(), LinearScale()).

required
title str

Axis title override. When omitted the field name is used.

required
Notes

These additional keyword arguments are honored on positional channels:

  • sort — ordinal domain order: a list of strings, "ascending" / "descending", or a channel shorthand such as "-y" to sort by the per-category aggregate of another channel.
  • axis — an Axis(...) instance, False to suppress the axis, or a raw axis dict.
  • stack — True / one of "zero", "normalize", "center", or a falsy spelling (False, "false", "null", "none") to disable stacking.
  • impute — the options dict Y takes, read with the axes swapped: written on x as the value channel it completes every series the layer draws along y (the key), fills a null or NaN x in a series, and adds no key for a null, NaN or infinite y. The options, their checks, what a series is and what a render refuses are written once, on Y; here the layer's secondary y2 stands where that text says x2, and x2 where it says y2.
  • format — a tick-format string, paired with format_type / formatType ("number" or "time").
  • legend — a Legend(...) instance or a raw legend dict. Honored (NF-B13): routed to the same per-channel legend-override style path Color(legend=...) uses, so an explicit Legend(orient=...) (or similar) takes effect on the chart's legend even though x carries no legend of its own. Per-channel precedence is color > x > y; if Color(legend=...) is also set, its value wins field-by-field. Bare legend=None / legend=False is a no-op (nothing is serialized) rather than a suppression: there is no "x's own legend" for that spelling to suppress, so — unlike Color/Size/Shape, which each own a legend surface — x cannot reach across channels and blank a different one's legend. Suppress the rendered legend from the channel that actually owns it, e.g. Color(legend=None).

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x=fm.X("hp", type_="Q"))
>>> fm.Chart(df).encode(x=fm.X("hp", bin=True))
>>> fm.Chart(df).encode(x=fm.X("hp", aggregate="mean"))
>>> fm.Chart(df).encode(x=fm.X("category", sort="-y"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"
aggregate str

Aggregation operation applied before mapping (e.g. "max"). It is one more op in the chart's (or layer's) one aggregate, grouped like x: x="min(v)", x2="max(v)" draws one span per group.

required

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x=fm.X("start"), x2=fm.X2("end"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(x="mean_hp", x_error=fm.XError("ci_hp"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(
...     x="mean_hp",
...     x_error=fm.XError("err_low"),
...     x_error2=fm.XError2("err_high"),
... )

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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 Bin(...) instance to control bin width or count; True uses automatic binning.

required
aggregate str

Aggregation operation applied before mapping (e.g. "mean", "sum", "count").

required
scale Scale

Explicit scale override (e.g. LogScale(), LinearScale()).

required
title str

Axis title override. When omitted the field name is used.

required
Notes

These additional keyword arguments are honored on positional channels:

  • sort — ordinal domain order: a list of strings, "ascending" / "descending", or a channel shorthand such as "-x" to sort by the per-category aggregate of another channel.
  • axis — an Axis(...) instance, False to suppress the axis, or a raw axis dict.
  • stack — True / one of "zero", "normalize", "center", or a falsy spelling (False, "false", "null", "none") to disable stacking.
  • impute — a dict of the options transform_impute takes (method, value, keyvals, frame), each checked as transform_impute checks it when the channel is built: a value that is not a dict, an option not in that list, a non-finite value and a malformed keyvals or frame raise ValueError. keyvals is an ordered sequence (list, tuple, range, array, Series, a generator, a dict's keys(), values() or items() view, read in insertion order) or a {"start", "stop", "step"} dict. A bare string (it iterates into characters), a byte string (it iterates into integers), or a set (no order, so the output would change from run to run; pass a list, e.g. sorted(keys)) and a mapping that is not a dict (pass a list, or dict(...) for the sequence form) are refused. Written on the value channel, it completes every series the layer draws along x: a series that lacks an x some row of the layer holds (or a keyvals entry) gains one row there, inserted at that key's place in the series, and a null or NaN y in a series is filled the same way. A null, NaN or infinite x adds no key. The fill is method: "value" (the default) fills value, which is 0 when omitted on a numeric column and must be given on a date, text or Boolean column; mean, median, min and max fill the series' own statistic over frame. A series is the rows that share the values of the channels the mark splits by: a colour the colour scale draws as categories (a text column, or an integer column an area colours) or as bins and, on the marks that draw them, shape, stroke_dash and detail. A colour drawn continuously splits nothing. A row null on one of those belongs to no series: it is neither filled nor drawn, and no key is completed for it. Each layer completes its own series, so an impute written on one layer is never read by a sibling. A render refuses an impute written on both x and y, one with no x channel to complete along, one beside the layer's own secondary y2, an x whose secondary x2 differs among rows sharing the key an imputed row copies, and a value of a kind the column cannot hold, each with the remedy named.
  • format — a tick-format string, paired with format_type / formatType ("number" or "time").
  • legend — a Legend(...) instance or a raw legend dict. Honored (NF-B13): routed to the same per-channel legend-override style path Color(legend=...) uses, so an explicit Legend(orient=...) (or similar) takes effect on the chart's legend even though y carries no legend of its own. Per-channel precedence is color > x > y; if Color(legend=...) is also set, its value wins field-by-field. Bare legend=None / legend=False is a no-op (nothing is serialized) rather than a suppression: there is no "y's own legend" for that spelling to suppress, so — unlike Color/Size/Shape, which each own a legend surface — y cannot reach across channels and blank a different one's legend. Suppress the rendered legend from the channel that actually owns it, e.g. Color(legend=None).

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(y=fm.Y("mpg", type_="Q"))
>>> fm.Chart(df).encode(y=fm.Y("mpg", aggregate="mean"))
>>> fm.Chart(df).encode(y=fm.Y("category", sort="-x"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"
aggregate str

Aggregation operation applied before mapping (e.g. "max"). It is one more op in the chart's (or layer's) one aggregate, grouped like y: y="min(v)", y2="max(v)" draws one span per group.

required

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(y=fm.Y("low"), y2=fm.Y2("high"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(y="mean_mpg", y_error=fm.YError("ci_mpg"))

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.

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"

Examples:

>>> import ferrum as fm
>>> fm.Chart(df).encode(
...     y="mean_mpg",
...     y_error=fm.YError("err_low"),
...     y_error2=fm.YError2("err_high"),
... )

to_encoding_spec_dict

to_encoding_spec_dict() -> dict

Return kwargs for the Rust EncodingSpec constructor / serde JSON.

Iterates this channel's own _honored_kwargs (the single source of truth) rather than a separate hard-coded key list, so a kwarg is serialized iff the channel honors it. Each honored key routes through _SPEC_DICT_HANDLERS to its serializer; keys with no handler (bin/aggregate) are honored for the warn guard but consumed via to_implicit_transforms, so they contribute nothing here. legend is the one key whose serializer depends on more than its own value, branching on _legend_surface: "own" routes through _emit_legend; "cascade" (X, Y) routes through _emit_legend_cascade_only instead, so a bare None/False cannot suppress a different channel's legend (see that function's docstring); on "none" legend is not honored, so nothing is emitted -- _validate_legend_value has already refused every value except the silent None/False.

Keys are emitted in _SPEC_DICT_ORDER so the dict layout is stable regardless of frozenset iteration order.

to_implicit_transforms

to_implicit_transforms() -> list

Return a list of transform objects derived from kwargs (bin, aggregate).

Both bin and aggregate transforms are returned as pending sentinels rather than concrete Rust objects. chart.to_spec() resolves them:

  • _PendingBin: single-chart path converts to an unnamed Bin (byte-stable); layered path converts to a named Bin fan-out so it does not corrupt the shared unnamed chain.
  • _PendingAggregate: defers groupby assignment until all sibling encoding channels are known (Altair-style auto-groupby).

option

option(name: str, default: Any = None) -> Any

Return the value of encoding option name, or default if unset.

Parameters:

Name Type Description Default
name str

The option key to look up (e.g. "sort", "axis").

required
default Any

Value returned when name is not present. Defaults to None.

None

Returns:

Type Description
Any

The option value, or default when the key is absent.