deepspatial.vis_utils.plot_3d_labels#
- deepspatial.vis_utils.plot_3d_labels(adata: AnnData, color_col: str = 'cell_class', palette: Dict[str, str] | None = None, spatial_key: str = 'spatial', z_key: str = 'z_coord', azim: float = -60.0, elev: float = 30.0, z_stretch: float = 1.0, point_size: float = 1.0, alpha: float = 0.8, max_points: int = 100000, bg_color: str = 'white', save_pdf: str | None = None, show: bool = True) Figure | None[source]#
Generate a static 3D scatter plot colored by categorical labels.
- Parameters:
adata (ad.AnnData) – Annotated data matrix.
color_col (str) – Column name in adata.obs representing the category.
palette (dict, optional) – Mapping of categories to hex color codes. Defaults to ‘tab20’.
spatial_key (str) – Key in adata.obsm containing XY spatial coordinates.
z_key (str) – Key in adata.obs containing Z coordinates.
azim (float) – Azimuthal viewing angle in degrees.
elev (float) – Elevation viewing angle in degrees.
z_stretch (float) – Scaling factor for the Z-axis aspect ratio.
point_size (float) – Scatter point size.
alpha (float) – Marker opacity (0.0 to 1.0).
max_points (int) – Max number of cells to render to prevent memory overflow.
bg_color (str) – Figure background color.
save_pdf (str, optional) – Path to save the output as a PDF file.
show (bool) – Whether to display the plot immediately. If False, returns the figure.
- Returns:
Figure object if show=False, else None.
- Return type:
matplotlib.figure.Figure or None