autoscale y to current xrange in view - matplotlib


U

urban_gibbon

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()
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top