d_multigraph#

DirectedMultiGraph plotting module.

Plotting#

phylozoo.viz.d_multigraph.plot_dmgraph(graph: DirectedMultiGraph, layout: str = 'spring', style: DMGraphStyle | None = None, ax: Any | None = None, show: bool = False, **layout_kwargs: Any) Any[source]#

Plot a DirectedMultiGraph.

This is the main public API function for plotting directed multigraphs. It handles layout computation, styling, and rendering using matplotlib.

Parameters:
  • graph (DirectedMultiGraph) – 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 (DMGraphStyle, 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:

matplotlib.axes.Axes

Raises:

PhyloZooLayoutError – If layout algorithm is not supported.

Examples

>>> from phylozoo.core.primitives.d_multigraph import DirectedMultiGraph
>>> from phylozoo.viz import plot_dmgraph
>>>
>>> G = DirectedMultiGraph(edges=[(1, 2), (2, 3)])
>>> ax = plot_dmgraph(G, layout='circular')

Styling#

Styling for DirectedMultiGraph plots.

This module provides styling configuration for DirectedMultiGraph visualizations.

class phylozoo.viz.d_multigraph.style.BaseStyle(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: object

Base styling configuration for all graph and network plots.

This class provides the common styling options shared across all visualization types.

Examples

>>> style = BaseStyle(node_color='blue')
>>> style.node_color
'blue'
edge_color: str = 'gray'#
edge_width: float = 2.0#
label_color: str = 'black'#
label_font_size: float = 10.0#
label_offset: float = 0.12#
node_color: str = 'lightblue'#
node_edge_color: str = 'black'#
node_edge_width: float = 1.5#
node_size: float = 500.0#
with_labels: bool = True#
class phylozoo.viz.d_multigraph.style.DMGraphStyle(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: BaseStyle

Styling configuration for DirectedMultiGraph plots.

This class extends BaseStyle with DirectedMultiGraph-specific options.

Examples

>>> style = DMGraphStyle(node_color='blue')
>>> style.node_color
'blue'
phylozoo.viz.d_multigraph.style.default_style() DMGraphStyle[source]#

Get the default style configuration for DirectedMultiGraph.

Returns:

Default style configuration.

Return type:

DMGraphStyle

Examples

>>> style = default_style()
>>> style.node_color
'lightblue'