Plotting
Plotting helpers from annnet.utils.plotting.
annnet.utils.plotting
Functions
edge_style_from_weights(graph, *, layer=None, min_width=0.5, max_width=5.0, color_mode='greys')
Compute visual edge styles (pen width and color) from effective weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
object
|
AnnNet-like object exposing |
required |
layer
|
str
|
Layer name for retrieving edge weights. Defaults to |
None
|
min_width
|
float
|
Minimum line width for edges. Default is 0.5. |
0.5
|
max_width
|
float
|
Maximum line width for edges. Default is 5.0. |
5.0
|
color_mode
|
('greys', 'signed')
|
Edge coloring mode:
- |
'greys'
|
Returns:
| Type | Description |
|---|---|
dict[int, dict[str, str]]
|
A mapping from edge index to a style dict with keys:
- |
Notes
- Invalid or missing weights default to 1.0.
- Normalization is performed across all edges in the graph.
plot(graph, *, backend='graphviz', layout='dot', layer=None, show_edge_labels=False, edge_label_keys=None, show_vertex_labels=True, vertex_label_key=None, use_weight_style=True, orphan_edges=True, suppress_warnings=True, **kwargs)
Build a fully styled graph object ready for rendering with Graphviz or Pydot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
object
|
AnnNet-like object with |
required |
backend
|
('graphviz', 'pydot')
|
Visualization backend to use. Default is |
'graphviz'
|
layout
|
str
|
Layout engine (e.g. |
'dot'
|
layer
|
str
|
Layer name for weight or label extraction. Default is |
None
|
show_edge_labels
|
bool
|
Whether to include weight and attribute labels on edges. Default is |
False
|
edge_label_keys
|
list of str
|
Extra edge attribute keys to display if |
None
|
show_vertex_labels
|
bool
|
Whether to label vertices with IDs or attributes. Default is |
True
|
vertex_label_key
|
str
|
Attribute key for vertex labels. If |
None
|
use_weight_style
|
bool
|
Whether to style edges based on weights. Default is |
True
|
orphan_edges
|
bool
|
Whether to render edges with missing endpoints. Default is |
True
|
suppress_warnings
|
bool
|
Suppress backend rendering warnings (stderr). Default is |
True
|
**kwargs
|
Additional keyword arguments forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
Digraph or Dot
|
A styled, backend-specific graph object suitable for rendering or exporting. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If an invalid |
Notes
- Edge styling and labels are applied before backend construction.
- If
show_edge_labels=True, edges are regenerated with label overrides.
render(obj, path, format='svg')
Render a Graphviz or Pydot graph object to disk and return the output path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Digraph or Dot
|
The graph object returned by |
required |
path
|
str
|
Destination file path (without extension if |
required |
format
|
('svg', 'png', 'raw')
|
Output format. Default is |
'svg'
|
Returns:
| Type | Description |
|---|---|
str
|
Full path to the written output file. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Notes
- Graphviz objects use the built-in
.render()API. - Pydot objects write directly via
.write_svg(),.write_png(), or.write_raw(). - The file extension is appended automatically if not present.