#

Note

This documents the development version of NetworkX. Documentation for the current release can be found here.

#

networkx.drawing.nx_pylab.draw_networkx_nodes

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)[source]

Draw the nodes of the graph G.

This draws only the nodes of the graph G.

Parameters
  • G (graph) – A networkx graph

  • pos (dictionary) – A dictionary with nodes as keys and positions as values. Positions should be sequences of length 2.

  • ax (Matplotlib Axes object, optional) – Draw the graph in the specified Matplotlib axes.

  • nodelist (list, optional) – Draw only specified nodes (default G.nodes())

  • node_size (scalar or array) – Size of nodes (default=300). If an array is specified it must be the same length as nodelist.

  • node_color (color or array of colors (default=’#1f78b4’)) – 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.

  • node_shape (string) – The shape of the node. Specification is as matplotlib.scatter marker, one of ‘so^>v<dph8’ (default=’o’).

  • alpha (float or array of floats) – The node transparency. This can be a single alpha value (default=None), 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).

  • cmap (Matplotlib colormap) – Colormap for mapping intensities of nodes (default=None)

  • vmin,vmax (floats) – Minimum and maximum for node colormap scaling (default=None)

  • linewidths ([None | scalar | sequence]) – Line width of symbol border (default =1.0)

  • edgecolors ([None | scalar | sequence]) – Colors of node borders (default = node_color)

  • label ([None| string]) – Label for legend

Returns

PathCollection of the nodes.

Return type

matplotlib.collections.PathCollection

Examples

>>> G = nx.dodecahedral_graph()
>>> nodes = nx.draw_networkx_nodes(G, pos=nx.spring_layout(G))

Also see the NetworkX drawing examples at https://networkx.github.io/documentation/latest/auto_examples/index.html