Revision: 3911
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3911&view=rev
Author:   jrevans
Date:     2007-10-03 16:05:30 -0700 (Wed, 03 Oct 2007)

Log Message:
-----------
Removed an erroneous print statment in backend_qt.py.
Added a feature to keep track of axes inversions.

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/axes.py
    trunk/matplotlib/lib/matplotlib/backends/backend_qt.py

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py     2007-10-03 22:23:48 UTC (rev 
3910)
+++ trunk/matplotlib/lib/matplotlib/axes.py     2007-10-03 23:05:30 UTC (rev 
3911)
@@ -503,6 +503,9 @@
         self.set_label(label)
         self.set_figure(fig)
 
+        self._invertedx = False
+        self._invertedy = False
+
         # this call may differ for non-sep axes, eg polar
         self._init_axis()
 
@@ -1500,10 +1503,25 @@
 
     ### data limits, ticks, tick labels, and formatting
 
+    def invert_xaxis(self, invert=True):
+        "Invert the x-axis if 'invert' is True."
+        self._invertedx = invert
+
+    def xaxis_inverted(self):
+        'Returns True if the x-axis is inverted.'
+        return self._invertedx
+
     def get_xlim(self):
-        'Get the x axis range [xmin, xmax]'
-        return self.viewLim.intervalx().get_bounds()
+        """Get the x-axis range [xmin, xmax]
 
+        NOTE: The returned values are always [xmin, xmax] such that
+              xmin < xmax; regardless of whether or not the axes are inverted.
+        """
+        bound1, bound2 = self.viewLim.intervalx().get_bounds()
+        if ( self._invertedx ):
+            return bound2, bound1
+        else:
+            return bound1, bound2
 
     def set_xlim(self, xmin=None, xmax=None, emit=True, **kwargs):
         """
@@ -1542,12 +1560,25 @@
         if xmin is None: xmin = old_xmin
         if xmax is None: xmax = old_xmax
 
+        # provided for backwards compatability
+        if ( xmax < xmin ):
+            # swap the values so that xmin < xmax and set inverted flag
+            tmp = xmin
+            xmin = xmax
+            xmax = tmp
+            self.invert_xaxis( True )
+
         if (self.transData.get_funcx().get_type()==mtrans.LOG10
             and min(xmin, xmax)<=0):
             raise ValueError('Cannot set nonpositive limits with log 
transform')
 
-        xmin, xmax = mtrans.nonsingular(xmin, xmax, increasing=False)
-        self.viewLim.intervalx().set_bounds(xmin, xmax)
+        if ( self._invertedx ):
+            xmax, xmin = mtrans.nonsingular(xmax, xmin, increasing=False)
+            self.viewLim.intervalx().set_bounds(xmax, xmin)
+        else:
+            xmin, xmax = mtrans.nonsingular(xmin, xmax, increasing=False)
+            self.viewLim.intervalx().set_bounds(xmin, xmax)
+
         if emit: self.callbacks.process('xlim_changed', self)
 
         return xmin, xmax
@@ -1623,10 +1654,26 @@
         return self.xaxis.set_ticklabels(labels, fontdict, **kwargs)
     set_xticklabels.__doc__ = cbook.dedent(set_xticklabels.__doc__) % 
martist.kwdocd
 
+    def invert_yaxis(self, invert=True):
+        "Invert the y-axis if 'invert' is True."
+        self._invertedy = invert
+
+    def yaxis_inverted(self):
+        'Returns True if the y-axis is inverted.'
+        return self._invertedy
+
     def get_ylim(self):
-        'Get the y axis range [ymin, ymax]'
-        return self.viewLim.intervaly().get_bounds()
+        """Get the y-axis range [xmin, xmax]
 
+        NOTE: The returned values are always [ymin, ymax] such that
+              ymin < ymax; regardless of whether or not the axes are inverted.
+        """
+        bound1, bound2 = self.viewLim.intervaly().get_bounds()
+        if ( self._invertedy ):
+            return bound2, bound1
+        else:
+            return bound1, bound2
+
     def set_ylim(self, ymin=None, ymax=None, emit=True, **kwargs):
         """
         set_ylim(self, *args, **kwargs):
@@ -1649,7 +1696,6 @@
         ACCEPTS: len(2) sequence of floats
         """
 
-
         if ymax is None and iterable(ymin):
             ymin,ymax = ymin
 
@@ -1663,12 +1709,25 @@
         if ymin is None: ymin = old_ymin
         if ymax is None: ymax = old_ymax
 
+        # provided for backwards compatability
+        if ( ymax < ymin ):
+            # swap the values so that ymin < ymax and set inverted flag
+            tmp = ymin
+            ymin = ymax
+            ymax = tmp
+            self.invert_yaxis( True )
+
         if (self.transData.get_funcy().get_type()==mtrans.LOG10
             and min(ymin, ymax)<=0):
             raise ValueError('Cannot set nonpositive limits with log 
transform')
 
-        ymin, ymax = mtrans.nonsingular(ymin, ymax, increasing=False)
-        self.viewLim.intervaly().set_bounds(ymin, ymax)
+        if ( self._invertedy ):
+            ymax, ymin = mtrans.nonsingular(ymax, ymin, increasing=False)
+            self.viewLim.intervaly().set_bounds(ymax, ymin)
+        else:
+            ymin, ymax = mtrans.nonsingular(ymin, ymax, increasing=False)
+            self.viewLim.intervaly().set_bounds(ymin, ymax)
+
         if emit: self.callbacks.process('ylim_changed', self)
 
         return ymin, ymax

Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py      2007-10-03 
22:23:48 UTC (rev 3910)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py      2007-10-03 
23:05:30 UTC (rev 3911)
@@ -135,7 +135,6 @@
 
     def resizeEvent( self, event ):
         if DEBUG: print 'resize (%d x %d)' % (event.size().width(), 
event.size().height())
-        print "JRE--DBG: qt : resizeEvent"
         qt.QWidget.resizeEvent( self, event )
         w = event.size().width()
         h = event.size().height()
@@ -147,7 +146,6 @@
         self.draw()
 
     def resize( self, w, h ):
-        print "JRE--DBG: qt : resize"
         # Pass through to Qt to resize the widget.
         qt.QWidget.resize( self, w, h )
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to