Skip to content

ferrum.repeat

Repeat sentinel for template-based field substitution in RepeatChart.

Typed sentinel namespace for RepeatChart templates.

Usage::

from ferrum import Repeat
Chart(data).encode(x=Repeat.column, y=Repeat.row, color="species").mark_point()

The placeholders are resolved by RepeatChart.expand() into concrete field names based on the chart's row= / column= / layer= lists. JSON serialisation (via to_repeat_dict) emits {"$repeat": "<axis>"}.

Repeat

Namespace for typed RepeatChart template sentinels.

Access the three sentinels via class attributes — do not instantiate Repeat directly:

Attributes:

Name Type Description
column _RepeatPlaceholder

Sentinel that resolves to the column-axis field for each cell.

row _RepeatPlaceholder

Sentinel that resolves to the row-axis field for each cell.

layer _RepeatPlaceholder

Sentinel that resolves to the layer-axis field for each cell.

Examples:

>>> import ferrum as fm
>>> base = (
...     fm.Chart(df)
...     .encode(x=fm.Repeat.column, y=fm.Repeat.row)
...     .mark_point()
... )
>>> grid = fm.RepeatChart(base, row=["mpg", "hp"], column=["mpg", "hp"])