我有一个问题,即在关闭带有绘图图的窗口之前,python igraph函数会阻止代码执行。是否有可能使其表现得像mathplotlib的pause()一样?我希望在代码执行期间更新图的图。
我使用了类似的功能
from igraph import *
layout = graph.layout("kk")
plot(graph, layout = layout)
谢谢!
答案 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)