且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Tkinter窗口中刷新matplotlib图?

更新时间:2023-11-24 08:35:58

这是因为xaxis& yaxis不会更改为新数据的范围,请更改您的refreshFigure,如下所示:

That is because the range of xaxis & yaxis doesn't change to new data's range, change your refreshFigure as following:

def refreshFigure(self,x,y):
    self.line1.set_data(x,y)
    ax = self.canvas.figure.axes[0]
    ax.set_xlim(x.min(), x.max())
    ax.set_ylim(y.min(), y.max())        
    self.canvas.draw()