Paul Smith wrote:
I'm plotting two curves in one subplot with twinx to allow different y scales.
The script below is an example.
When zooming in using zoom-to-rect on Tk's navigation toolbar2 (TkAgg is my
backend) I think the x axis part of the zoom is happening twice. Rubberbanding
the example from x=20 to 80 results in a zoomed x range of about 32 to 68,
which is about what you'd expect for zooming with the same range twice.
Is there a way of restricting this to only one zoom?
Paul
------------
from pylab import *
f=figure(1)
ax1=f.add_subplot(111)
ax1.plot(arange(100))
ax2=twinx(ax1)
ax2.plot(-arange(100),'g')
draw()
Hi,
there was the above mail on the users list.
The problem is that "release_zoom" in backend_bases.py is called twice
in the above case if zoomed to a twinx'ed plot. One way to fix this
behavior is to set a "twin" attribute to the axes instance. Attached is
a patch against the 0.91 trunk.
John: is this okay or is there a better way to fix the problem?
Manuel
Index: backend_bases.py
===================================================================
--- backend_bases.py (revision 5028)
+++ backend_bases.py (working copy)
@@ -1704,6 +1704,9 @@
return
xmin, ymin, xmax, ymax = lim
+
+ if a._twin:
+ continue
# zoom to rect
lastx, lasty = a.transData.inverse_xy_tup( (lastx, lasty) )
Index: axes.py
===================================================================
--- axes.py (revision 5028)
+++ axes.py (working copy)
@@ -447,6 +447,7 @@
sharex=None, # use Axes instance's xaxis info
sharey=None, # use Axes instance's yaxis info
label='',
+ twinax=False,
**kwargs
):
"""
@@ -500,6 +501,9 @@
self._mastery = False
if sharex: sharex._masterx = True
if sharey: sharey._mastery = True
+ #
+ self._twin = False
+ if twinax: self._twin = True
self.set_label(label)
self.set_figure(fig)
@@ -5010,7 +5014,8 @@
right
"""
- ax2 = self.figure.add_axes(self.get_position(), sharex=self, frameon=False)
+ ax2 = self.figure.add_axes(self.get_position(), sharex=self, frameon=False,
+ twinax=True)
ax2.yaxis.tick_right()
ax2.yaxis.set_label_position('right')
self.yaxis.tick_left()
@@ -5026,7 +5031,8 @@
top
"""
- ax2 = self.figure.add_axes(self.get_position(), sharey=self, frameon=False)
+ ax2 = self.figure.add_axes(self.get_position(), sharey=self, frameon=False,
+ twinax=True)
ax2.xaxis.tick_top()
ax2.xaxis.set_label_position('top')
self.xaxis.tick_bottom()
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Register now and save $200. Hurry, offer ends at 11:59 p.m.,
Monday, April 7! Use priority code J8TLD2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel