您将需要更新轴的dataLim,然后基于dataLim更新轴的viewLim。合适的方法是
axes.relim()和
ax.autoscale_view()方法。您的示例如下所示:
import randomimport matplotlib.pyplot as pyplotpyplot.ion()x = range(10)y = lambda m: [m*random.random() for i in range(10)]pLine, = pyplot.plot(x, y(1))for i in range(10): pLine.set_ydata(y(i+1))ax = pyplot.gca()# recompute the ax.dataLimax.relim()# update ax.viewLim using the new dataLimax.autoscale_view()pyplot.draw()



