smx.plotting.theme#
SMX visual theme system.
All plotting helpers accept an optional theme argument of type
SMXTheme. When omitted, DEFAULT_THEME is used.
Example — using the default theme:
from smx.plotting import plot_zone_ranking_over_spectrum
plot_zone_ranking_over_spectrum(..., output_path="out.html")
Example — overriding selected fields:
from smx.plotting.theme import SMXTheme
my_theme = SMXTheme(font_family="Georgia", colorscale="Blues")
plot_zone_ranking_over_spectrum(..., output_path="out.html", theme=my_theme)
Attributes#
Classes#
Visual style configuration shared across all SMX plots. |
Functions#
|
Return the rgb string from compositing rgb_str over white at opacity. |
|
Build a Plotly colorscale whose colors are pre-blended with white. |
Module Contents#
- class smx.plotting.theme.SMXTheme[source]#
Visual style configuration shared across all SMX plots.
Parameters#
- templatestr
Plotly layout template (e.g.
'plotly_white','simple_white').- font_familystr
CSS font-family string applied to all text in the figure.
- font_sizeint
Base font size (px) for axis labels, tick labels, and annotations.
- class_colorsdict[str, str]
Mapping from class label to hex/CSS color string. Labels not present fall back to
fallback_palette.- fallback_palettelist[str]
Ordered list of colors used for class labels not found in
class_colors.- colorscalestr
Plotly colorscale name used for LRC-score zone bands and the colorbar.
- zone_opacityfloat
Opacity applied to zone background rectangles (vrect).
- reference_line_colorstr
Color for the overall reference/mean spectrum line.
- reference_line_widthint
Stroke width (px) for the reference spectrum line.
- reference_line_dashstr
Plotly dash style for the reference spectrum (e.g.
'dash').- class_line_widthint
Stroke width (px) for per-class mean spectrum lines.
- threshold_colorstr
Color for reconstructed threshold spectrum lines.
- threshold_line_widthint
Stroke width (px) for threshold spectrum lines.
- threshold_line_dashstr
Plotly dash style for threshold lines.
- zone_boundary_colorstr
Color for the vertical dotted zone-boundary lines.
- zone_boundary_widthint
Stroke width (px) for zone boundary lines.
- zone_boundary_dashstr
Plotly dash style for zone boundary lines.
- colorbar_thicknessint
Thickness (px) of the LRC-score colorbar.
- colorbar_lenfloat
Fractional length of the colorbar relative to the plot height.
- annotation_font_sizeint
Font size (px) used for zone-label annotations above the plot.
- fallback_palette: List[str] = ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#a65628', '#f781bf', '#999999']#
- resolve_class_color(label: str, _used: list | None = None) str[source]#
Return the color for label, falling back to the palette if needed.
Parameters#
- labelstr
Class label to resolve.
- _usedlist, optional
Mutable list of already-consumed palette colors, used when assigning palette colors sequentially across multiple labels.
- smx.plotting.theme.DEFAULT_THEME#
- smx.plotting.theme.blend_with_white(rgb_str: str, opacity: float) str[source]#
Return the rgb string from compositing rgb_str over white at opacity.
Used to match colorscale colors to the actual rendered appearance of zone background rectangles, which are drawn with fractional opacity over a white plot background.
- smx.plotting.theme.build_blended_colorscale(colorscale: str, opacity: float, n_stops: int = 32) list[source]#
Build a Plotly colorscale whose colors are pre-blended with white.
Parameters#
- colorscalestr
Plotly colorscale name (e.g.
'YlOrRd').- opacityfloat
Opacity used when compositing over white.
- n_stopsint
Number of discrete color stops in the returned colorscale.
Returns#
- list of [float, str]
Colorscale in Plotly’s
[[position, color], ...]format.