Skip to main content
`Ctrl`+`K`

# 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, margins=None, hide_ticks=True)

  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 (default list(G))

      Draw only specified nodes

    node_size scalar or array (default=300)

      Size of nodes. If an array 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 (default=’o’)

      The shape of the node. Specification is as matplotlib.scatter marker, one of ‘so^>v<dph8’.

    alpha float or array of floats (default=None)

      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).

    cmap Matplotlib colormap (default=None)

      Colormap for mapping intensities of nodes

    vmin,vmax floats or None (default=None)

      Minimum and maximum for node colormap scaling

    linewidths[None | scalar | sequence] (default=1.0)

      Line width of symbol border

    edgecolors[None | scalar | sequence] (default = node_color)

      Colors of node borders. 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 `scatter` for more details.

    label[None | string]

      Label for legend

    margins float or 2-tuple, optional

      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`, which uses the Matplotlib default.

    hide_ticks bool, optional

      Hide ticks of axes. When `True` (the default), ticks and ticklabels are removed from the axes. To set ticks and tick labels to the pyplot default, use `hide_ticks=False`.

  Returns:
    matplotlib.collections.PathCollection

      `PathCollection` of the nodes.

  See also

  `draw`
  `draw_networkx`
  `draw_networkx_edges`
  `draw_networkx_labels`
  `draw_networkx_edge_labels`

  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.org/documentation/latest/auto_examples/index.html