draw_planar#
- draw_planar(G, **kwargs)[source]#
Draw a planar networkx graph
Gwith planar layout.This is a convenience function equivalent to:
nx.draw(G, pos=nx.planar_layout(G), **kwargs)
- Parameters:
- Ggraph
A planar networkx graph
- kwargsoptional keywords
See
draw_networkxfor a description of optional keywords.
- Raises:
- NetworkXException
When
Gis not planar
See also
Notes
The layout is computed each time this function is called. For repeated drawing it is much more efficient to call
planar_layoutdirectly and reuse the result:>>> G = nx.path_graph(5) >>> pos = nx.planar_layout(G) >>> nx.draw(G, pos=pos) # Draw the original graph >>> # Draw a subgraph, reusing the same node positions >>> nx.draw(G.subgraph([0, 1, 2]), pos=pos, node_color="red")
Examples
>>> G = nx.path_graph(4) >>> nx.draw_planar(G)