如何防止python igraph plot()执行阻塞?

时间:2019-10-08 09:10:51

标签: python plot igraph

我有一个问题,即在关闭带有绘图图的窗口之前,python igraph函数会阻止代码执行。是否有可能使其表现得像mathplotlib的pause()一样?我希望在代码执行期间更新图的图。

我使用了类似的功能

from igraph import *
layout = graph.layout("kk")
plot(graph, layout = layout)

谢谢!

1 个答案:

答案 0 :(得分:0)

我以这种方式解决了我的问题

from igraph import *
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
OUT_PLOT_NAME = "/home/anton/Temp/graph_plot.png"

def plot_graph(G):
    layout = G.layout("kk")
    out = plot(G, OUT_PLOT_NAME, layout = layout)    
    img = mpimg.imread(OUT_PLOT_NAME)
    imgplot = plt.imshow(img)