draw(G, pos=None, ax=None, **kwds)
Draw the graph as a simple representation with no node labels or edge labels and using the full Matplotlib figure area and no axis labels by default. See draw_networkx() for more full-featured drawing that allows title, axis labels etc.
This function has the same name as pylab.draw and pyplot.draw so beware when using :None:None:`from networkx import *`
since you might overwrite the pylab.draw function.
With pyplot use
>>> import matplotlib.pyplot as plt >>> G = nx.dodecahedral_graph() >>> nx.draw(G) # networkx draw() >>> plt.draw() # pyplot draw()
Also see the NetworkX drawing examples at https://networkx.org/documentation/latest/auto_examples/index.html
A networkx graph
A dictionary with nodes as keys and positions as values. If not specified a spring layout positioning will be computed. See networkx.drawing.layout
for functions that compute node positions.
Draw the graph in specified Matplotlib axes.
See networkx.draw_networkx() for a description of optional keywords.
Draw the graph G with Matplotlib.
>>> G = nx.dodecahedral_graph()See :
... nx.draw(G)
... nx.draw(G, pos=nx.spring_layout(G)) # use spring layout
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.drawing.nx_pylab.draw_networkx
networkx.drawing.nx_pylab.draw
networkx.drawing.layout.spiral_layout
networkx.drawing.nx_pylab.draw_networkx_labels
networkx.drawing.nx_pylab.draw_networkx_edge_labels
networkx.drawing.nx_pylab.draw_networkx_edges
networkx.drawing.nx_pylab.draw_spring
networkx.drawing.nx_pylab.draw_networkx_nodes
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them