Plotting¶
Draw a 2-D scatter plot of an embedding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
res
|
np.ndarray of shape (n_samples, >=2)
|
Embedding coordinates; the first two columns are plotted. |
required |
labels
|
array-like of shape (n_samples,)
|
Per-point values mapped to colors via |
None
|
ax
|
Axes
|
Existing axes to draw into. If None, creates a new figure and axes. |
None
|
pt_size
|
float
|
Marker size. |
5
|
marker
|
str
|
Marker style. |
"o"
|
opacity
|
float
|
Marker transparency (alpha). |
1
|
cmap
|
str
|
Colormap name. |
"Spectral"
|
equal_aspect
|
bool
|
Whether to set equal aspect ratio. |
True
|
**kwargs
|
Extra arguments forwarded to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
fig |
Figure
|
The created figure. |
ax |
Axes
|
The axes containing the scatter plot. |
Draw a 3-D scatter plot of an embedding (first three columns).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
res
|
np.ndarray of shape (n_samples, >=3)
|
Embedding coordinates; the first three columns are plotted. |
required |
labels
|
array-like of shape (n_samples,)
|
Per-point values mapped to colors via |
None
|
ax
|
Axes
|
Existing 3-D axes to draw into. If None, creates a new figure and axes. |
None
|
pt_size
|
float
|
Marker size. |
5
|
marker
|
str
|
Marker style. |
"o"
|
opacity
|
float
|
Marker transparency (alpha). |
1
|
cmap
|
str
|
Colormap name. |
"Spectral"
|
**kwargs
|
Extra arguments forwarded to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
fig |
Figure
|
The created figure. |
ax |
Axes
|
The 3-D axes containing the scatter plot. |
Plot Riemannian metric using ellipses. Adapted from Megaman.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
emb
|
np.ndarray of shape (n_samples, n_features)
|
Embedding coordinates. Must have at least 2 columns. |
required |
L
|
scipy.sparse.spmatrix of shape (n_samples, n_samples)
|
Graph Laplacian defining the reference geometry. Required if H_emb is None. |
required |
H_emb
|
np.ndarray of shape (n_samples, n_features, n_features)
|
Inverse (dual) Riemannian metric at each point. If None, computed from L using RiemannMetric. |
None
|
ax
|
Axes
|
Existing axes to draw into. If None, creates a new figure and axes. |
None
|
n_plot
|
int
|
Number of ellipses to draw (subset of points). |
50
|
std
|
float
|
Standard deviation scaling for ellipse size. Adjust manually for clarity. |
1
|
alpha
|
float
|
Transparency of ellipses. |
0.1
|
title
|
str
|
Plot title. |
"Riemannian metric"
|
title_fontsize
|
int
|
Title font size. |
10
|
labels
|
array-like of shape (n_samples,)
|
Per-point labels mapped to colors via cmap. |
None
|
pt_size
|
float
|
Marker size for points. |
1
|
cmap
|
str
|
Colormap for labels. |
"Spectral"
|
figsize
|
tuple of (float, float)
|
Figure width and height. |
(8, 8)
|
random_state
|
int or RandomState
|
RNG seed for sampling points. |
None
|
**kwargs
|
dict
|
Extra arguments forwarded to matplotlib. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
ax |
Axes
|
The axes containing the plot. |
Notes
Computing the Riemannian metric may require O(n_samples²) memory if all-pairs distances are materialized. For large datasets, use landmark mode or avoid this method.
References
Perraul-Joncas, D., & Meila, M. (2013). Non-linear dimensionality reduction: Riemannian metric estimation and the problem of geometric discovery. arXiv preprint arXiv:1305.7255.
Plot the first n_eigenvectors diffusion components as scatter strips.
Lays out one panel per component, either horizontally or as vertically
stacked slender rows (orientation).
Produce an animated GIF from a list of MAP training snapshots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshots
|
list[dict]
|
Each dict must have an |
required |
dpi
|
int
|
Figure DPI. |
120
|
color
|
None, array-like, or single color
|
Per-point coloring (see TopOGraph.visualize_optimization for details). |
None
|
filename
|
str or None
|
Output GIF path. Auto-generated if None. |
None
|
point_size
|
float
|
Scatter marker size. |
3.0
|
fps
|
int
|
Frames per second. |
20
|
tag
|
str
|
Label used in title and default filename. |
'msTopoMAP'
|
overlay_metrics
|
bool
|
Draw metric values on each frame if present. |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the generated GIF. |