微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在 Spyder 中绘制 igraph

如何解决如何在 Spyder 中绘制 igraph

以下代码来自: https://towardsdatascience.com/newbies-guide-to-python-igraph-4e51689c35b4

当我尝试在 Spyder Anaconda 上绘制此图时,我收到一条错误消息...如下所示

import igraph
from igraph import *
print(igraph.__version__)

# Create a directed graph
g = Graph(directed=True)
# Add 5 vertices
g.add_vertices(5)

# Add ids and labels to vertices
for i in range(len(g.vs)):
    g.vs[i]["id"]= i
    g.vs[i]["label"]= str(i)
# Add edges
g.add_edges([(0,2),(0,1),3),(1,(2,4),(3,4)])
# Add weights and edge labels
weights = [8,6,3,5,4,9]
g.es['weight'] = weights
g.es['label'] = weights


visual_style = {}
out_name = "graph.png"
# Set bBox and margin
visual_style["bBox"] = (400,400)
visual_style["margin"] = 27
# Set vertex colours
visual_style["vertex_color"] = 'white'
# Set vertex size
visual_style["vertex_size"] = 45
# Set vertex lable size
visual_style["vertex_label_size"] = 22
# Don't curve the edges
visual_style["edge_curved"] = False
# Set the layout
my_layout = g.layout_lgl()
visual_style["layout"] = my_layout
# Plot the graph
plot(g,out_name,**visual_style)

文件“C:\ProgramData\Anaconda3\lib\site-packages\igraph\drawing\utils.py”,第 410 行,getattr 引发 AttributeError("绘图不可用")

AttributeError:绘图不可用

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。