Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

Node ColormapΒΆ

Draw a graph with matplotlib, color by degree. You must have matplotlib for this to work.

../../_images/sphx_glr_plot_node_colormap_001.png
# Author: Aric Hagberg (hagberg@lanl.gov)

import matplotlib.pyplot as plt
import networkx as nx

G = nx.cycle_graph(24)
pos = nx.spring_layout(G, iterations=200)
nx.draw(G, pos, node_color=range(24), node_size=800, cmap=plt.cm.Blues)
plt.show()

Total running time of the script: ( 0 minutes 0.174 seconds)

Gallery generated by Sphinx-Gallery