Skip to content

RenderContext

yohou.plotting.RenderContext dataclass

Typed context passed to facet render callbacks.

Replaces the previous 6-positional-arg callback signature with named, self-documenting fields.

Parameters

Name Type Description Default
fig Figure

The subplots figure to add traces to.

required
sub_df DataFrame

Subset DataFrame with "time" plus one or more value columns. For panel faceting, contains one value column. For column faceting, contains the columns specified in column_groups.

required
display_name str

The name of the overlaid entity (member name when facet_by="group", group name when facet_by="member", column name when facet_by="column").

required
entity_idx int

Index of the overlaid entity in the color palette. In non-panel (column) mode this is always 0; such callbacks should use display_name to look up colours from their own mapping.

required
row int

Subplot row (1-indexed).

required
col int

Subplot column (1-indexed).

required
facet_by str

"group", "member", or "column" - indicates the faceting axis. "column" is set automatically by the non-panel (column-mode) code path; it is not a value accepted by facet_figure's own facet_by parameter.

required
facet_name str

The facet axis value (group name when facet_by="group", member name when facet_by="member", column name when facet_by="column").

required
group_name str

Panel group name, always available for context. For column faceting this equals the column name.

required
member_name str

Panel member name, always available for context. For column faceting this equals the column name.

required

See Also

LegendTracker : De-duplicates legend entries across subplots.

Notes

facet_figure is the factory that creates faceted figures and passes RenderContext to callbacks.

Source Code

Source code in src/yohou/plotting/_utils.py
@dataclass(frozen=True)
class RenderContext:
    """Typed context passed to facet render callbacks.

    Replaces the previous 6-positional-arg callback signature with
    named, self-documenting fields.

    Parameters
    ----------
    fig : go.Figure
        The subplots figure to add traces to.
    sub_df : pl.DataFrame
        Subset DataFrame with ``"time"`` plus one or more value columns.
        For panel faceting, contains one value column.  For column
        faceting, contains the columns specified in ``column_groups``.
    display_name : str
        The name of the overlaid entity (member name when
        ``facet_by="group"``, group name when ``facet_by="member"``,
        column name when ``facet_by="column"``).
    entity_idx : int
        Index of the overlaid entity in the color palette. In non-panel
        (column) mode this is always 0; such callbacks should use
        ``display_name`` to look up colours from their own mapping.
    row : int
        Subplot row (1-indexed).
    col : int
        Subplot column (1-indexed).
    facet_by : str
        ``"group"``, ``"member"``, or ``"column"`` - indicates the
        faceting axis.  ``"column"`` is set automatically by the non-panel
        (column-mode) code path; it is not a value accepted by
        `facet_figure`'s own ``facet_by`` parameter.
    facet_name : str
        The facet axis value (group name when ``facet_by="group"``,
        member name when ``facet_by="member"``, column name when
        ``facet_by="column"``).
    group_name : str
        Panel group name, always available for context.  For column
        faceting this equals the column name.
    member_name : str
        Panel member name, always available for context.  For column
        faceting this equals the column name.

    See Also
    --------
    [`LegendTracker`][yohou.plotting._utils.LegendTracker] : De-duplicates legend entries across subplots.

    Notes
    -----
    ``facet_figure`` is the factory that creates faceted figures and passes
    ``RenderContext`` to callbacks.
    """

    fig: go.Figure
    sub_df: pl.DataFrame
    display_name: str
    entity_idx: int
    row: int
    col: int
    facet_by: str
    facet_name: str
    group_name: str
    member_name: str