Python igraph不会在iPython笔记本中显示顶点和边缘标签

时间:2015-04-10 13:28:29

标签: python ipython-notebook igraph anaconda graph-visualization

我正在尝试使用igraph Python可视化具有顶点和边缘标签的简单网络。我使用的是OS X 10.2.2,Python 2.7.9 Anaconda,igraph 0.7.1,iPython 3.0。当我使用Python解释器构建代码时,它会正确显示绘图。但是,当我尝试对iPython笔记本执行相同操作时,它不会显示顶点和边缘标签。知道怎么解决它?这是我的代码。

import igraph

G = igraph.Graph(directed = True)

G.add_vertices(n = 8)
G.vs['name'] = range(8)
G.vs['label'] = range(8)
print G.vs['label']

G.add_edges([(0,1),(0,2),(1,3),(2,3),(3,4),(4,3),(5,4),(6,4),(7,5),(7,6)])
G.es['weight'] = [2,4,3,2,1,1,2,4,3,2]
G.es["name"] = range(10)
G.es["label"] = range(10)

G.summary()

igraph.plot(G, bbox = (300,300), vertex_label_color = 'black', 
        vertex_label_size = 10, vertex_size = 20, vertex_color = 'white',
                                      edge_width = [edge for edge in G.es['weight']])

0 个答案:

没有答案