在Python中运行代码时如何阻止igraph弹出?

问题描述

我正在使用 igraph 来绘制我的 graphframes 图表并且它不断弹出输出图像。我必须手动关闭窗口,以便进程可以继续运行。

这是我的代码

from igraph import Graph,plot

ig = Graph.TupleList(g.edges.collect(),directed=False)
out = plot(ig,vertex_size=10,bBox=(0,500,500))
out.save("graph.png")

如何禁用弹出窗口?

解决方法

如果您查看 plot 函数的参考,您可以看到有一个名为 target 的参数。 target 的默认值是 None,它会尝试打开图像查看器,但未指定目标。你也可以给它一个带有文件名的字符串。 https://igraph.org/python/doc/api/igraph.drawing.html#plot

尝试像这样使用它:

out = plot(ig,target='graph.png',vertex_size=10,bbox=(0,500,500))