autoscale y to current xrange in view - matplotlib

urban_gibbon adrian.h.hill at gmail.com
Wed Mar 23 14:17:00 EDT 2011


Hi I am very new to python and matplotlib, so please forgive me if this is a naive question

I have a question regarding the y autoscale.  I would like it to scale to only the current data in view, not all the data.  At the moment the y axes are scaled to some data not currently shown and so very distorted.  Is there a way to do this?

Thanks for any help

So far my script looks like this.


import pylab
import matplotlib.pyplot as plt
import numpy

pylab.cla()

f=numpy.loadtxt("pattern_5K.ascii")

x = f[:,0]
data = f[:,1]
model = f[:,2]
diff = f[:,3]

plt.close('all')

f, (ax1, ax2) = plt.subplots(2, sharex=True, sharey=False)
ax1.set_xlim((21,22))

ax1.plot(x, data, '.', color = 'red', markersize=1),
ax1.plot(x, model, '-', color = 'blue', linewidth = 0.5)

ax1.set_title('Pattern')
ax2.plot(x, diff,'-',color='magenta',linewidth = 0.5)

f.subplots_adjust(hspace=0)
plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False)

plt.show()



More information about the Python-list mailing list