m_multigraph#
MixedMultiGraph plotting module.
Plotting#
- phylozoo.viz.m_multigraph.plot_mmgraph(graph: MixedMultiGraph, layout: str = 'spring', style: MGraphStyle | None = None, ax: Any | None = None, show: bool = False, **layout_kwargs: Any) Any[source]#
Plot a MixedMultiGraph.
This is the main public API function for plotting mixed multigraphs. It handles layout computation, styling, and rendering using matplotlib.
- Parameters:
graph (MixedMultiGraph) – The graph to plot.
layout (str, optional) – Layout algorithm. NetworkX: ‘spring’, ‘circular’, ‘kamada_kawai’, ‘planar’, ‘random’, ‘shell’, ‘spectral’, ‘spiral’, ‘bipartite’. Graphviz: ‘dot’, ‘neato’, ‘fdp’, ‘sfdp’, ‘twopi’, ‘circo’. By default ‘spring’.
style (MGraphStyle, optional) – Styling configuration. If None, uses default style. By default None.
ax (matplotlib.axes.Axes, optional) – Existing axes to plot on. If None, creates new figure and axes. By default None.
show (bool, optional) – If True, automatically display the plot using plt.show(). By default False.
**layout_kwargs – Additional parameters for layout computation.
- Returns:
The axes object containing the plot.
- Return type:
- Raises:
PhyloZooLayoutError – If layout algorithm is not supported.
Examples
>>> from phylozoo.core.primitives.m_multigraph import MixedMultiGraph >>> from phylozoo.viz import plot >>> >>> G = MixedMultiGraph(directed_edges=[(1, 2)], undirected_edges=[(2, 3)]) >>> ax = plot(G, layout='spring')
Styling#
Styling for MixedMultiGraph plots.
This module provides styling configuration for MixedMultiGraph visualizations.
- class phylozoo.viz.m_multigraph.style.MGraphStyle(node_color: str = 'lightblue', node_size: float = 500.0, node_edge_color: str = 'black', node_edge_width: float = 1.5, edge_color: str = 'gray', edge_width: float = 2.0, with_labels: bool = True, label_offset: float = 0.12, label_font_size: float = 10.0, label_color: str = 'black')[source]#
Bases:
BaseStyleStyling configuration for MixedMultiGraph plots.
This class extends BaseStyle with MixedMultiGraph-specific options. MixedMultiGraphs can have both directed and undirected edges.
Examples
>>> style = MGraphStyle(node_color='blue') >>> style.node_color 'blue'
- phylozoo.viz.m_multigraph.style.default_style() MGraphStyle[source]#
Get the default style configuration for MixedMultiGraph.
- Returns:
Default style configuration.
- Return type:
Examples
>>> style = default_style() >>> style.node_color 'lightblue'