plot_habitat_clustering_pca_2d
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_clustering_pca_2d(features: ndarray, labels: ndarray, *, centers: ndarray | None = None, title: str | None = None, n_clusters: int | None = None, palette: Sequence[str] | None = None, alpha: float = 0.7, marker_size: int = 20, center_marker: str = 'X', center_size: int = 50, center_color: str = '#000000', show_grid: bool = True, grid_alpha: float = 0.3, max_legend_items: int = 10)[source]
Two-dimensional PCA scatter of habitat clustering units.
Each point is one clustering unit (supervoxel, voxel or pooled habitat row) coloured by its assigned habitat id. Optional
centersare projected with the same PCA fitted onfeatures, matching the v0.1plot_cluster_results(..., plot_3d=False)behaviour for population-level habitat clustering.- Parameters:
features – Feature matrix, shape
(n_samples, n_features).labels – Habitat assignment per row, shape
(n_samples,).centers – Optional centroid matrix, shape
(n_habitats, n_features).title – Figure title; defaults to a population-level English caption.
n_clusters – Selected cluster count for the default title; inferred from
labelswhen omitted.palette – Optional colour cycle; defaults to the active matplotlib cycle from
use_style().alpha – Scatter-point transparency in
[0, 1].marker_size – Scatter marker area in points squared.
center_marker – Marker style for centroids.
center_size – Centroid marker area in points squared.
center_color – Centroid colour.
show_grid – Draw a light dashed grid on both axes.
grid_alpha – Grid-line transparency.
max_legend_items – Hide the legend when the habitat count exceeds this.
- Returns:
A matplotlib
Figure. The caller owns persistence and display.