Revision: 6844
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6844&view=rev
Author:   jrevans
Date:     2009-01-28 17:55:07 +0000 (Wed, 28 Jan 2009)

Log Message:
-----------
Updated ConversionInterface to recieve the associated calling Axis instance for 
each of the methods.
Updated appropriate calls in other code.
Modified DateConverter to use units for timezone specification.

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/axis.py
    trunk/matplotlib/lib/matplotlib/dates.py
    trunk/matplotlib/lib/matplotlib/units.py

Modified: trunk/matplotlib/lib/matplotlib/axis.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axis.py     2009-01-27 17:41:33 UTC (rev 
6843)
+++ trunk/matplotlib/lib/matplotlib/axis.py     2009-01-28 17:55:07 UTC (rev 
6844)
@@ -939,7 +939,7 @@
         converter = munits.registry.get_converter(data)
         if converter is None: return False
         self.converter = converter
-        default = self.converter.default_units(data)
+        default = self.converter.default_units(self, data)
         #print 'update units: default="%s", units=%s"'%(default, self.units)
         if default is not None and self.units is None:
             self.set_units(default)
@@ -955,7 +955,7 @@
         if self.converter is None:
             return
 
-        info = self.converter.axisinfo(self.units)
+        info = self.converter.axisinfo(self, self.units)
         if info is None:
             return
         if info.majloc is not None and self.major.locator!=info.majloc:
@@ -982,7 +982,7 @@
             #print 'convert_units returning identity: units=%s, 
converter=%s'%(self.units, self.converter)
             return x
 
-        ret =  self.converter.convert(x, self.units)
+        ret =  self.converter.convert(self, x, self.units)
         #print 'convert_units converting: axis=%s, units=%s, converter=%s, 
in=%s, out=%s'%(self, self.units, self.converter, x, ret)
         return ret
 

Modified: trunk/matplotlib/lib/matplotlib/dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/dates.py    2009-01-27 17:41:33 UTC (rev 
6843)
+++ trunk/matplotlib/lib/matplotlib/dates.py    2009-01-28 17:55:07 UTC (rev 
6844)
@@ -1004,29 +1004,56 @@
 
 
 class DateConverter(units.ConversionInterface):
+    """The units are equivalent to the timezone."""
 
     @staticmethod
-    def axisinfo(unit):
+    def axisinfo(axis, unit):
         'return the unit AxisInfo'
-        if unit=='date':
-            majloc = AutoDateLocator()
-            majfmt = AutoDateFormatter(majloc)
-            return units.AxisInfo(
-                majloc = majloc,
-                majfmt = majfmt,
-                label='',
-                )
-        else: return None
+        # make sure that the axis does not start at 0
+        ax = axis.axes
 
+        if axis is ax.get_xaxis():
+            xmin, xmax = ax.dataLim.intervalx
+            if xmin==0.:
+                # no data has been added - let's set the default datalim.
+                # We should probably use a better proxy for the datalim
+                # have been updated than the ignore setting
+                dmax = today = datetime.date.today()
+                dmin = today-datetime.timedelta(days=10)
+
+                ax._process_unit_info(xdata=(dmin, dmax))
+                dmin, dmax = ax.convert_xunits([dmin, dmax])
+
+                ax.viewLim.intervalx = dmin, dmax
+                ax.dataLim.intervalx = dmin, dmax
+        elif axis is ax.get_yaxis():
+            ymin, ymax = ax.dataLim.intervaly
+            if ymin==0.:
+                # no data has been added - let's set the default datalim.
+                # We should probably use a better proxy for the datalim
+                # have been updated than the ignore setting
+                dmax = today = datetime.date.today()
+                dmin = today-datetime.timedelta(days=10)
+
+                ax._process_unit_info(ydata=(dmin, dmax))
+                dmin, dmax = ax.convert_yunits([dmin, dmax])
+
+                ax.viewLim.intervaly = dmin, dmax
+                ax.dataLim.intervaly = dmin, dmax
+
+        majloc = AutoDateLocator(tz=unit)
+        majfmt = AutoDateFormatter(majloc, tz=unit)
+        return units.AxisInfo( majloc=majloc, majfmt=majfmt, label='' )
+
     @staticmethod
-    def convert(value, unit):
+    def convert(axis, value, unit):
         if units.ConversionInterface.is_numlike(value): return value
         return date2num(value)
 
     @staticmethod
-    def default_units(x):
+    def default_units(axis, x):
         'Return the default unit for *x* or None'
-        return 'date'
+        return None
 
 
 units.registry[datetime.date] = DateConverter()

Modified: trunk/matplotlib/lib/matplotlib/units.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/units.py    2009-01-27 17:41:33 UTC (rev 
6843)
+++ trunk/matplotlib/lib/matplotlib/units.py    2009-01-28 17:55:07 UTC (rev 
6844)
@@ -69,20 +69,20 @@
     sequences) and convert them to values mpl can use
     """
     @staticmethod
-    def axisinfo(unit):
-        'return an units.AxisInfo instance for unit'
+    def axisinfo(axis, unit):
+        'return an units.AxisInfo instance for axis with the specified units'
         return None
 
     @staticmethod
-    def default_units(x):
-        'return the default unit for x or None'
+    def default_units(axis, x):
+        'return the default unit for x or None for the given axis'
         return None
 
     @staticmethod
-    def convert(obj, unit):
+    def convert(axis, obj, unit):
         """
-        convert obj using unit.  If obj is a sequence, return the
-        converted sequence.  The ouput must be a sequence of scalars
+        convert obj using unit for the specified axis.  If obj is a sequence,
+        return the converted sequence.  The ouput must be a sequence of scalars
         that can be used by the numpy array layer
         """
         return obj


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:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to