matplotlib FuncAnimation问题

时间:2014-09-29 12:56:43

标签: python matplotlib plot

我正在尝试动态显示我正在运行的遗传拟合的结果(这样我就可以决定何时停止)。代码几乎是以下内容:

#vars stands for a bunch of variables required for the simulation and the fit

import matplotlib.pyplot as plt

class plotSim:
    def __init__(self, vars, line)
        self.vars = vars
        self.line = line

    def animate(self,i):
        simulation_fit_result = perform_simulation_fit(self.vars)
        self.line.set_ydata(simulation_fit_result)

fig, ax = plt.subplots(figsize=(20,8))
ax.semilogy(x_experimental,y_experimental)
line, = ax.semilogy(x_simulation,y_simulation) #initializing the line with the simulation performed with the initial values to fit

plotfit = plotSim(vars,line)
ani = animation.FuncAnimation(fig, plotfit.animate,interval=1000)
plt.show()

我无法看到与我发现Google搜索的其他示例的区别。在我的情况下,模拟成功执行(因为我可以看到我打印的一些东西用于检查)但没有显示数字(甚至没有静态的数字)。使用plt.ion()和plt.draw()时,我也遇到了同样的问题。我在Ubuntu 12.04下使用Spyder 2.1.9 IDE,这有什么影响吗?

感谢所有回答的人的帮助。

0 个答案:

没有答案