节点色图

用matplotlib绘制一个图表,按度数着色。你必须有Matplotlib才能工作。

../../_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()

脚本的总运行时间: (0分0.140秒)

Gallery generated by Sphinx-Gallery