Revision: 5383
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5383&view=rev
Author:   jdh2358
Date:     2008-06-04 10:49:17 -0700 (Wed, 04 Jun 2008)

Log Message:
-----------
try to handle xaxis_date more gracefully when no data has been added

Modified Paths:
--------------
    branches/v0_91_maint/lib/matplotlib/axes.py
    branches/v0_91_maint/src/_transforms.cpp
    branches/v0_91_maint/src/_transforms.h

Modified: branches/v0_91_maint/lib/matplotlib/axes.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/axes.py 2008-06-04 16:53:48 UTC (rev 
5382)
+++ branches/v0_91_maint/lib/matplotlib/axes.py 2008-06-04 17:49:17 UTC (rev 
5383)
@@ -1,5 +1,5 @@
 from __future__ import division, generators
-import math, sys, warnings
+import math, sys, warnings, datetime
 
 import numpy as npy
 
@@ -1858,10 +1858,25 @@
         tz is the time zone to use in labeling dates.  Defaults to rc value.
         """
 
+        if self.dataLim.is_ignore():
+            # 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)
+            self._process_unit_info(xdata=(dmin, dmax))
+
+            dmin, dmax = self.convert_xunits([dmin, dmax])
+
+            self.viewLim.intervalx().set_bounds(dmin, dmax)
+            self.viewLim.intervalx().set_bounds(dmin, dmax)
+
+
         locator = self.xaxis.get_major_locator()
         if not isinstance(locator, mdates.DateLocator):
             locator = mdates.AutoDateLocator(tz)
             self.xaxis.set_major_locator(locator)
+            locator.refresh()
 
         formatter = self.xaxis.get_major_formatter()
         if not isinstance(formatter, mdates.DateFormatter):
@@ -1873,11 +1888,24 @@
 
         tz is the time zone to use in labeling dates.  Defaults to rc value.
         """
+        if self.dataLim.is_ignore():
+            # 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)
+            self._process_unit_info(xdata=(dmin, dmax))
 
+            dmin, dmax = self.convert_xunits([dmin, dmax])
+            self.viewLim.intervaly().set_bounds(dmin, dmax)
+            self.viewLim.intervaly().set_bounds(dmin, dmax)
+
+
         locator = self.yaxis.get_major_locator()
         if not isinstance(locator, mdates.DateLocator):
             locator = mdates.AutoDateLocator(tz)
             self.yaxis.set_major_locator(locator)
+            locator.refresh()
 
         formatter = self.xaxis.get_major_formatter()
         if not isinstance(formatter, mdates.DateFormatter):

Modified: branches/v0_91_maint/src/_transforms.cpp
===================================================================
--- branches/v0_91_maint/src/_transforms.cpp    2008-06-04 16:53:48 UTC (rev 
5382)
+++ branches/v0_91_maint/src/_transforms.cpp    2008-06-04 17:49:17 UTC (rev 
5383)
@@ -348,6 +348,13 @@
 }
 
 Py::Object
+Bbox::is_ignore(const Py::Tuple &args) {
+  _VERBOSE("Bbox::ignore");
+  args.verify_length(0);
+  return Py::Int(_ignore);
+}
+
+Py::Object
 Bbox::overlapsx(const Py::Tuple &args, const Py::Dict &kwargs) {
   _VERBOSE("Bbox::overlapsx");
   args.verify_length(1);
@@ -2349,6 +2356,7 @@
   add_varargs_method("ymin",   &Bbox::ymin, "ymin()\n");
 
   add_varargs_method("ignore",          &Bbox::ignore, "ignore(int)");
+  add_varargs_method("is_ignore",       &Bbox::is_ignore, "is_ignore()");
   add_varargs_method("scale",   &Bbox::scale, "scale(sx,sy)");
   add_varargs_method("deepcopy", &Bbox::deepcopy, "deepcopy()\n");
 }

Modified: branches/v0_91_maint/src/_transforms.h
===================================================================
--- branches/v0_91_maint/src/_transforms.h      2008-06-04 16:53:48 UTC (rev 
5382)
+++ branches/v0_91_maint/src/_transforms.h      2008-06-04 17:49:17 UTC (rev 
5383)
@@ -357,8 +357,11 @@
   //set the ignore attr
   Py::Object ignore(const Py::Tuple &args);
 
+  //return the ignore setting
+  Py::Object is_ignore(const Py::Tuple &args);
 
 
+
   Point* ll_api() {return _ll;}
   Point* ur_api() {return _ur;}
 private:


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

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to