plot_habitat_feature_components
Note
This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.
- plot_habitat_feature_components(data: 'HabitatFeaturePanel' | 'HabitatFeatureComparison', *, method: Literal['pca', 'cva'] = 'cva', n_components: int = 2, features: Sequence[str] | None = None, habitats: Sequence[int] | None = None, annotate_subjects: bool | None = None, show_loadings: bool = True, title: str | None = None) Figure[source]
Habitat contrast on a few CVA or PCA component scores.
This is the overflow figure when the pair x feature Cliff’s-delta heatmap would be too tall: compute a few axes, then show how H1..Hk differ on those scores (same job as the delta / bar plots; the “features” are CV1/PC1/…). It is not a 2-D embedding to admire.
Default
method="cva"is multi-class Fisher LDA (canonical variates that separate habitats) – not two-block CCA. Whenn_features >= n_samples - n_classesthe CVA path reduces with PCA first and the title saysCVA (PCA-preprocessed). Passmethod="pca"for unsupervised components.Features are z-scored before the fit so Energy and
volume_fractionshare one Euclidean space. A loadings row names the original features that represent each retained axis.- Parameters:
data – Long panel or a
HabitatFeatureComparison.method –
"cva"(default) or"pca".n_components – Requested axes. CVA keeps at most
n_habitats - 1.features – Optional feature subset. Default: all panel features.
habitats – Optional habitat subset.
annotate_subjects – Unused. Kept so existing callers that passed it still construct; the figure is habitat contrast on scores, not a subject scatter.
show_loadings – Draw one loadings panel per retained component.
title – Optional figure title. Default names the contrast and the
p features -> k axesreduction.
- Returns:
The matplotlib
Figure.- Raises:
HABITAPIError – Unknown
method, empty panel, or a still- singular CVA after PCA.