smx.plotting.threshold#
plot_threshold_spectrum: visualise a multivariate threshold overlaid on the original spectral zone, coloured by class.
Requires plotly. The dependency is optional — import errors produce a
clear, actionable message rather than a hard package-load failure.
Functions#
|
Reconstruct a threshold to spectrum space and save an HTML plot. |
Module Contents#
- smx.plotting.threshold.plot_threshold_spectrum(lrc_natural_df: pandas.DataFrame, row_index: int, spectral_zones_original: Dict[str, pandas.DataFrame], pca_info_dict_original: Dict, y_labels: pandas.Series, output_path: str | pathlib.Path | None, class_colors: Dict[str, str] | None = None, theme: smx.plotting.theme.SMXTheme | None = None, width: int | None = 900, height: int | None = 450, return_df: bool = False) None | pandas.Series[source]#
Reconstruct a threshold to spectrum space and save an HTML plot.
The plot overlays the reconstructed multivariate threshold (in red) on top of the individual sample spectra for the chosen spectral zone, coloured by class label. The figure is always displayed; set return_df=True to return the threshold spectrum Series.
Parameters#
- lrc_natural_dfpd.DataFrame
LRC DataFrame with natural-scale thresholds. Must contain columns
'Zone','Threshold_Natural', and'Node_Natural'.- row_indexint
Row of lrc_natural_df to visualise.
- spectral_zones_originaldict[str, pd.DataFrame]
Spectral zones extracted from the unpreprocessed calibration data.
- pca_info_dict_originaldict
PCA info from
smx.zones.aggregation.ZoneAggregatorfitted on the natural (unpreprocessed) data.- y_labelspd.Series
Class labels aligned with the calibration data rows.
- output_pathstr or Path, optional
Destination path for the output
.htmlfile. IfNone, no file is written.- class_colorsdict, optional
Mapping of class label → colour string. Explicit values override the theme. Defaults to the theme’s
class_colors.- themeSMXTheme, optional
Visual theme. Defaults to
smx.plotting.theme.DEFAULT_THEME.- return_dfbool, default False
If
True, return the threshold spectrum Series.
Raises#
- ImportError
If
plotlyis not installed.