The help for xlim() says:
Set/Get the xlimits of the current axes::
xmin, xmax = xlim() # return the current xlim
xlim( (xmin, xmax) ) # set the xlim to xmin, xmax
xlim( xmin, xmax ) # set the xlim to xmin, xmax
but it also has the unexpected behavior of turning off autoscaling if used:
···
-----
import matplotlib.pyplot as plt
plt.clf()
ax = plt.subplot(211)
plt.draw()
print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',plt.xlim()
ax.plot([0,.5,1,1.5,2],[0,1,0,1,0])
plt.draw()
print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim(),'\n'
ax = plt.subplot(212)
plt.draw()
print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim()
plt.plot([0,.5,1,1.5,2],[0,1,0,1,0])
plt.draw()
print 'autoscale X on: ',ax._autoscaleXon,' xlim: ',ax.get_xlim(),'\n'
-----
returns:
>>> import xlim_unautoscale
autoscale X on: True xlim: (0.0, 1.0)
autoscale X on: False xlim: (0.0, 1.0)
autoscale X on: True xlim: (0.0, 1.0)
autoscale X on: True xlim: (0.0, 2.0)
I assume that this is because xlim() calls set_xlim() which has auto=False as a default keyword...
expected behavior: xlim() should behave exactly like get_xlim()
ditto for ylim()
M