smx.plotting.threshold ====================== .. py:module:: smx.plotting.threshold .. autoapi-nested-parse:: 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 --------- .. autoapisummary:: smx.plotting.threshold.plot_threshold_spectrum Module Contents --------------- .. py:function:: 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: Optional[Union[str, pathlib.Path]], class_colors: Optional[Dict[str, str]] = None, theme: Optional[smx.plotting.theme.SMXTheme] = None, width: Optional[int] = 900, height: Optional[int] = 450, return_df: bool = False) -> Union[None, pandas.Series] 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_df : pd.DataFrame LRC DataFrame with natural-scale thresholds. Must contain columns ``'Zone'``, ``'Threshold_Natural'``, and ``'Node_Natural'``. row_index : int Row of *lrc_natural_df* to visualise. spectral_zones_original : dict[str, pd.DataFrame] Spectral zones extracted from the *unpreprocessed* calibration data. pca_info_dict_original : dict PCA info from :class:`smx.zones.aggregation.ZoneAggregator` fitted on the natural (unpreprocessed) data. y_labels : pd.Series Class labels aligned with the calibration data rows. output_path : str or Path, optional Destination path for the output ``.html`` file. If ``None``, no file is written. class_colors : dict, optional Mapping of class label → colour string. Explicit values override the theme. Defaults to the theme's ``class_colors``. theme : SMXTheme, optional Visual theme. Defaults to :data:`smx.plotting.theme.DEFAULT_THEME`. return_df : bool, default False If ``True``, return the threshold spectrum Series. Raises ------ ImportError If ``plotly`` is not installed.