finesse.plotting.graph.plot_nx_graph

finesse.plotting.graph.plot_nx_graph(network, layout, node_labels=True, node_attrs=False, edge_attrs=False, node_color_key=None, edge_color_key=None, label_font_size=12, attr_font_size=6, edge_font_size=6, bounding_ellipses=True, format: Literal['png', 'svg'] = 'svg', path: pathlib._local.Path | None = None, show=True, **kwargs)[source]

Plot graph with NetworkX.

Parameters
networknetworkx.Graph

The network to plot.

layoutstr

The layout type to use. Any layout algorithm provided by networkx.drawing.layout is supported.

node_labelsbool, optional

Show node names; defaults to True.

node_attrsbool or list, optional

Show node data. This can be True, in which case all node data is shown, or a list, in which case only the specified keys are shown. Defaults to True.

edge_attrsbool or list, optional

Show edge data. This can be True, in which case all edge data is shown, or a list, in which case only the specified keys are shown. Defaults to True.

node_color_keycallable, optional

Key function accepting a node and its attribute dict and returning a group. Each group is assigned a unique color. If not specified, nodes are not colored.

edge_color_keycallable, optional

Key function accepting an edge (u, v) and its attribute dict and returning a group. Each group is assigned a unique color. If not specified, edges are not colored.

label_font_size, attr_font_size, edge_font_sizeint, optional

Font size for node labels, attributes and edges. Defaults to 12, 6 and 6, respectively.

bounding_ellipses: bool, optional

Hijack the node label bounding boxes to draw the node labels inside of an ellipse (similar to graphviz neato layout). This guarantees the label is readable, but the arrow direction might not always be clear and might not combine well with node_color_key. Defaults to True.

pathPath or None

Save the resulting image to the given path. Defaults to None, which saves in a temporary file that is displayed if ‘show’ is set to True.

showbool, optional

Whether to show the resulting image. In Jupyter environments, shows the plot inline, otherwise opens a webbrowser for svgs and PIL for pngs. Defaults to True.

Other Parameters
kwargs

Anything else supported by networkx.drawing.nx_pylab.draw().

Raises
ValueError

If the specified layout is not supported.

Exception

If the graph cannot be represented with the specified layout.