Plotting module¶
Plotting functions.
- pygenstability.plotting.plot_scan(all_results: dict[str, Any], figsize: tuple[float, float] = (6, 5), scale_axis: bool = True, figure_name: str | Path | None = 'scan_results.pdf', use_plotly: bool = False, live: bool = True, plotly_filename: str = 'scan_results.html', n_clusters_log_scale: bool = True) Any[source]¶
Plot results of pygenstability with matplotlib or plotly.
- Parameters:
all_results (dict) – results of pygenstability scan
figsize (tuple) – matplotlib figure size
scale_axis (bool) – display scale of scale index on scale axis
figure_name (str) – name of matplotlib figure
use_plotly (bool) – use matplotlib or plotly backend
live (bool) – for plotly backend, open browser with pot
plotly_filename (str) – filename of .html figure from plotly
n_clusters_log_scale (bool) – draw the # clusters axis on a log scale
- pygenstability.plotting.plot_scan_plotly(all_results: dict[str, Any], live: bool = False, filename: str | None = 'clusters.html') tuple[Any, Any][source]¶
Plot results of pygenstability with plotly.
- pygenstability.plotting.plot_single_partition(graph: Any, all_results: dict[str, Any], scale_id: int, edge_color: str = '0.5', edge_width: float = 0.5, node_size: float = 100) None[source]¶
Plot the community structures for a given scale.
- Parameters:
graph (networkx.Graph) – graph to plot
all_results (dict) – results of pygenstability scan
scale_id (int) – index of scale to plot
folder (str) – folder to save figures
edge_color (str) – color of edges
edge_width (float) – width of edges
node_size (float) – size of nodes
ext (str) – extension of figures files
- pygenstability.plotting.plot_optimal_partitions(graph: Any, all_results: dict[str, Any], edge_color: str = '0.5', edge_width: float = 0.5, folder: str | Path = 'optimal_partitions', ext: str = '.pdf', show: bool = False) None[source]¶
Plot the community structures at each optimal scale.
- Parameters:
graph (networkx.Graph) – graph to plot
all_results (dict) – results of pygenstability scan
edge_color (str) – color of edges
edge_width (float) – width of edgs
folder (str) – folder to save figures
ext (str) – extension of figures files
show (bool) – show each plot with plt.show() or not
- pygenstability.plotting.plot_communities(graph: Any, all_results: dict[str, Any], folder: str | Path = 'communities', edge_color: str = '0.5', edge_width: float = 0.5, ext: str = '.pdf') None[source]¶
Plot the community structures at each scale in a folder.
- Parameters:
graph (networkx.Graph) – graph to plot
all_results (dict) – results of pygenstability scan
folder (str) – folder to save figures
edge_color (str) – color of edges
edge_width (float) – width of edgs
ext (str) – extension of figures files
- pygenstability.plotting.plot_communities_matrix(graph: Any, all_results: dict[str, Any], folder: str | Path = 'communities_matrix', ext: str = '.pdf') None[source]¶
Plot communities at all scales in matrix form.
- Parameters:
graph (array) – as a numpy matrix
all_results (dict) – clustring results
folder (str) – folder to save figures
ext (str) – figure file format
- pygenstability.plotting.plot_scan_plt(all_results: dict[str, Any], figsize: tuple[float, float] = (6, 5), scale_axis: bool = True, figure_name: str | Path | None = 'scan_results.svg', n_clusters_log_scale: bool = True) list[Any][source]¶
Plot results of pygenstability with matplotlib.
Layout (top → bottom): stability + #clusters; ttprime heatmap with block-NVI overlay; NVI(t). Selected scales are marked by red dashed verticals across all panels and k=N text labels above the top panel.
- pygenstability.plotting.plot_clustered_adjacency(adjacency: Any, all_results: dict[str, Any], scale: int, labels: list[str] | None = None, figsize: tuple[float, float] = (12, 10), cmap: str = 'Blues', figure_name: str | Path = 'clustered_adjacency.pdf') None[source]¶
Plot the clustered adjacency matrix of the graph at a given scale.
- Parameters:
adjacency (ndarray or sparse matrix) – adjacency matrix to plot
all_results (dict) – results of PyGenStability
scale (int) – scale index for clustering
labels (list) – node labels, or None
figsize (tubple) – figure size
cmap (str) – colormap for matrix elements
figure_name (str) – filename of the figure with extension