DJElbow DJElbow - 2 years ago 199
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.

Answer Source
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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download