phenotypic.sdk_.viz.figures package#

Figure construction helpers and the centralized Plotly theme.

Re-exports the public theme surface from _theme so callers (and the forthcoming @figure decorator) can import it from the package root.

phenotypic.sdk_.viz.figures.apply_theme(fig: Figure) Figure[source]#

Apply the PhenoTypic theme to fig in place and return it.

Ensures the "phenotypic" template is registered, then sets the figure to use it composed with Plotly’s default template ("plotly+phenotypic"). Composition preserves Plotly’s built-in trace defaults while letting the PhenoTypic layer override layout styling (colorway, fonts, axes, legend).

Traces (fig.data) are never read, deleted, or mutated; only fig.layout.template is set. The function returns the same figure object it was given and is idempotent – applying it repeatedly leaves a single combined template and the traces untouched.

Parameters:

fig (Figure) – The figure to theme.

Returns:

The same fig object, with its layout template set to the composed "plotly+phenotypic" template.

Return type:

Figure

Example

>>> import plotly.graph_objects as go
>>> fig = go.Figure(go.Scatter(x=[1, 2], y=[3, 4]))
>>> themed = apply_theme(fig)
>>> themed is fig
True
>>> len(themed.data)
1
phenotypic.sdk_.viz.figures.phenotypic_mpl_context() Iterator[None][source]#

Context manager applying phenotypic_rc() via rc_context.

Use around figure construction so the theme is scoped and never leaks into a caller’s global rcParams:

with phenotypic_mpl_context():
    fig = analyzer.show()
    fig.savefig(buf, format="png")
Yields:

None; the themed rcParams are active for the duration of the block.

Return type:

Iterator[None]

phenotypic.sdk_.viz.figures.phenotypic_rc() dict[str, Any][source]#

Return the PhenoTypic matplotlib rcParams dict (DESIGN.md “07”).

Suitable for matplotlib.rcParams.update(...) or matplotlib.rc_context(phenotypic_rc()). Numeric tick labels render in JetBrains Mono; axis labels / titles in IBM Plex Sans. The Okabe-Ito series order anchors axes.prop_cycle so the first plotted series is brand navy.

Returns:

A fresh dict of rcParam name -> value.

Return type:

dict[str, Any]

phenotypic.sdk_.viz.figures.register_phenotypic_template() None[source]#

Build and register the "phenotypic" Plotly template.

Constructs a plotly.graph_objects.layout.Template carrying the brand palette, Okabe-Ito colorway, IBM Plex Sans typography, and the axis / grid / legend styling from DESIGN.md, then stores it in plotly.io.templates under PHENOTYPIC_TEMPLATE_NAME.

The function is idempotent: it rebuilds and re-assigns the template on every call, so importing this module (which calls it once) and any later explicit calls leave a single, identical entry. It is invoked automatically at import time.

Example

>>> import plotly.io as pio
>>> register_phenotypic_template()
>>> "phenotypic" in pio.templates
True
Return type:

None