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
figin 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; onlyfig.layout.templateis 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
figobject, 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()viarc_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
rcParamsdict (DESIGN.md “07”).Suitable for
matplotlib.rcParams.update(...)ormatplotlib.rc_context(phenotypic_rc()). Numeric tick labels render in JetBrains Mono; axis labels / titles in IBM Plex Sans. The Okabe-Ito series order anchorsaxes.prop_cycleso the first plotted series is brand navy.
- phenotypic.sdk_.viz.figures.register_phenotypic_template() None[source]#
Build and register the
"phenotypic"Plotly template.Constructs a
plotly.graph_objects.layout.Templatecarrying the brand palette, Okabe-Itocolorway, IBM Plex Sans typography, and the axis / grid / legend styling fromDESIGN.md, then stores it inplotly.io.templatesunderPHENOTYPIC_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