使用Matplotlib和iPython,如何将x和y轴限制重置为自动缩放?

DJE*_*bow 7 python matplotlib ipython

使用matplotlib和iPython,我有一堆我想要查看的图(一个接一个).某些图仅包含0到1的值,有些包含数百万的值.

使用以下方法设置y轴限制后:

ylim((.7,1))
Run Code Online (Sandbox Code Playgroud)

我希望能够重置此设置以自动设置限制(就像之前所做的那样).我找不到正确的方法.

tac*_*ell 13

ax = plt.gca()  # get the current axes
ax.relim()      # make sure all the data fits
ax.autoscale()  # auto-scale
# only needed mpl < 1.5
# ax.figure.canvas.draw_idle()       # re-draw the figure
Run Code Online (Sandbox Code Playgroud)