NetworkX

Previous topic

networkx.draw

Next topic

networkx.draw_networkx_nodes

networkx.draw_networkx

draw_networkx(G, pos, with_labels=True, **kwds)

Draw the graph G with given node positions pos

Usage:

>>> G=nx.dodecahedral_graph()
>>> pos=nx.spring_layout(G)
>>> nx.draw_networkx(G,pos)

This is same as ‘draw’ but the node positions must be specified in the variable pos. pos is a dictionary keyed by vertex with a two-tuple of x-y positions as the value. See networkx.layout for functions that compute node positions.

An optional matplotlib axis can be provided through the optional keyword ax.

with_labels contols text labeling of the nodes

Also see:

draw_networkx_nodes() draw_networkx_edges() draw_networkx_labels()