Hi,
I've encountered behavior in the svn trunk that I think is a bug.
Namely, the axes view limits are reset to the data limits upon a UI
event callback. In the attached test script for example, the plot
initially displays with the correct view limits (between -10 and 10 on
the X axis). However, when a key is pressed, the view is automatically
(and falsely) reset to encompass the entire data limits. I believe this
behavior has changed since 0.91.
Thanks,
Andrew
import pylab
import numpy
class ShowIt:
def on_key_press(self,event):
print 'received key',repr(event.key)
for ax in [self.ax1,self.ax2]:
xlim = ax.get_xlim()
ylim = ax.get_ylim()
ax.plot([0,0],'kx')
print 'set xlim',xlim
print 'set ylim',ylim
ax.set_xlim(xlim)
ax.set_ylim(ylim)
xlim = ax.get_xlim()
ylim = ax.get_ylim()
print 'got xlim',xlim
print 'got ylim',ylim
print
pylab.draw()
def show_it(self,fig):
ax1 = fig.add_subplot(2,1,1)
x1 = numpy.linspace(-100,100,100)
y1 = numpy.sin( x1/30.0 )
ax1.plot(x1,y1,'o')
xlim = [-10,10]
ylim = [-1,1]
ax2 = fig.add_subplot(2,1,2)
x2 = numpy.linspace(-100,100,100)
y2 = numpy.sin( x1/30.0 )
ax2.plot(x2,y2,'o')
ax2.set_xlim([-10,10])
ax2.set_ylim([-1,1])
self.ax1 = ax1
self.ax2 = ax2
for ax in [ax1,ax2]:
print 'set xlim',xlim
print 'set ylim',ylim
ax.set_xlim(xlim)
ax.set_ylim(ylim)
xlim = ax.get_xlim()
ylim = ax.get_ylim()
print 'got xlim',xlim
print 'got ylim',ylim
print
fig.canvas.mpl_connect('key_press_event', self.on_key_press)
fig = pylab.figure()
showit = ShowIt()
showit.show_it(fig)
pylab.show()
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel