DJElbow DJElbow - 9 months ago 49
Python Question

Using Matplotlib and iPython, How to reset x and y axis limits to Autoscale?

Using matplotlib and iPython, I have a bunch of plots that I am trying to view (one after the other). Some plots only contain values from 0 to 1 and some contain values in the millions.

After setting the y axis limits using:


I want to be able to reset this to set the limits automatically (as it would have done before). I am having trouble finding the correct approach.

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