如何使用python的matplotlib
库输出彩色图形(每个顶点都有自己的 colored颜色 )?是否有任何方法可以调整每个顶点的特定 colored颜色 ?
不使用 colored颜色 的代码示例:
import networkx as nx
import matplotlib.pyplot as plt
class Graph:
def __init__(self, edges):
self._edges = edges
def visualize(self):
vg = nx.Graph()
vg.add_edges_from(self._edges)
nx.draw_networkx(vg)
plt.show()
nodes = [['A', 'B'], ['A', 'C'], ['B', 'D'], ['C', 'D'],
['C', 'E'], ['D', 'F'], ['E', 'F']]
G = Graph(nodes)
G.visualize()
这就是我想看到的: