draw_networkx_nodes(G, pos, nodelist=None, node_size=300, node_color='#1f78b4', node_shape='o', alpha=None, cmap=None, vmin=None, vmax=None, ax=None, linewidths=None, edgecolors=None, label=None, margins=None)
This draws only the nodes of the graph G.
A networkx graph
A dictionary with nodes as keys and positions as values. Positions should be sequences of length 2.
Draw the graph in the specified Matplotlib axes.
Draw only specified nodes
Size of nodes. If an array it must be the same length as nodelist.
Node color. Can be a single color or a sequence of colors with the same length as nodelist. Color can be string or rgb (or rgba) tuple of floats from 0-1. If numeric values are specified they will be mapped to colors using the cmap and vmin,vmax parameters. See matplotlib.scatter for more details.
The shape of the node. Specification is as matplotlib.scatter marker, one of 'so^>v<dph8'.
The node transparency. This can be a single alpha value, in which case it will be applied to all the nodes of color. Otherwise, if it is an array, the elements of alpha will be applied to the colors in order (cycling through alpha multiple times if necessary).
Colormap for mapping intensities of nodes
Minimum and maximum for node colormap scaling
Line width of symbol border
Colors of node borders
Label for legend
Sets the padding for axis autoscaling. Increase margin to prevent clipping for nodes that are near the edges of an image. Values should be in the range [0, 1]
. See matplotlib.axes.Axes.margins
for details. The default is :None:None:`None`
, which uses the Matplotlib default.
:None:None:`PathCollection`
of the nodes.
Draw the nodes of the graph G.
>>> G = nx.dodecahedral_graph()
... nodes = nx.draw_networkx_nodes(G, pos=nx.spring_layout(G))
Also see the NetworkX drawing examples at https://networkx.org/documentation/latest/auto_examples/index.html
See :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.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_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