Revision: 7512
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7512&view=rev
Author:   jdh2358
Date:     2009-08-20 23:15:07 +0000 (Thu, 20 Aug 2009)

Log Message:
-----------
make autodateformatter customizable

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

Modified: trunk/matplotlib/lib/matplotlib/dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/dates.py    2009-08-20 23:11:44 UTC (rev 
7511)
+++ trunk/matplotlib/lib/matplotlib/dates.py    2009-08-20 23:15:07 UTC (rev 
7512)
@@ -413,12 +413,15 @@
     # Or more simply, perhaps just a format string for each
     # possibility...
 
-    def __init__(self, locator, tz=None):
+    def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'):
         """
+        Autofmt the date labels.  The default format is the one to use
+        if none of the times in scaled match
         """
         self._locator = locator
         self._tz = tz
-        self._formatter = DateFormatter("%b %d %Y %H:%M:%D", tz)
+        self.defaultfmt = defaultfmt
+        self._formatter = DateFormatter(self.defaultfmt, tz)
         self.scaled = {
            365.0  : '%Y',
            30.    : '%b %Y',
@@ -432,11 +435,14 @@
         keys = self.scaled.keys()
         keys.sort()
 
+        fmt = self.defaultfmt
+
         for k in keys:
            if k>=scale:
-              self._formatter = DateFormatter(self.scaled[k])
+              fmt = self.scaled[k]
               break
 
+        self._formatter = DateFormatter(fmt)
         return self._formatter(x, pos)
 
 


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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to