In your example, you are adding the axes to the figure twice: axes = self.figure.add_subplot(1, 1, 1) self.figure.add_axes(axes)
add_subplot both creates and adds the axes to the figure, so it is unnecessary to later add it. add_axes is intended for axes that have been created directly from the Axes constructor. Unfortunately, special care needs to be taken for overlapping axes (something that matplotlib could maybe improve on), so as you saw, the zooming happens twice. Also, perhaps we should consider raising an exception when the same Axes is added to the Figure twice. (First I'll have to ensure there's no legitimate reason to do so.) In any case, simply removing the second line above appears to be enough to get this to work correctly. Cheers, Mike Jervis Whitley wrote: > Hi, > > Could anyone help me with the following problem I am having. > > http://dpaste.com/64913/ > > The code listed above should be enough to reproduce the problem. > > I on using the zoom function from the toolbar, I find that the figure limits > are set to a smaller size than the zoom i selected - a kind of 'double zoom'. > > > I was able to track down the problem to backend_bases.py in the matplotlib > distribution (current release). > > Inside this file there is a member called 'release_zoom' > > there is a section of code that says.. > > for cur_xypress in self._xypress: > > lastx, lasty, a, ind, lim, trans = cur_xypress > # code > a.transData.inverted() > # code > a.set_xlim((x0, x1)) # etc.. > > > I am finding that there are two items in self._xypress, and that > the 'a' in both of them (axes i think) are the same object > i.e a1 is a2 == True > > this means that a.transData.inverted() is called twice on the same axes. > The first time through the for loop it gets the limits correct, the > second time, they are incorrect > because of the second call to inverted. > > I have implemented a shoddy fix where i check that if the axes is the same > as one that is seen before, I just continue. > > Is anyone else able to see this, or is it just something in the way > i've set up my > original pasted code? > > Cheers, > > Jervis > > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited time, > vendors submitting new applications to BlackBerry App World(TM) will have > the opportunity to enter the BlackBerry Developer Challenge. See full prize > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users