[Scipy-svn] r3154 - in trunk/Lib/sandbox/timeseries: . plotlib
scipy-svn@scip...
scipy-svn@scip...
Mon Jul 9 11:11:05 CDT 2007
Author: pierregm
Date: 2007-07-09 11:11:00 -0500 (Mon, 09 Jul 2007)
New Revision: 3154
Modified:
trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py
trunk/Lib/sandbox/timeseries/tseries.py
Log:
tseries : align_with returns a series (instead of a singleton list) if only two series are given as arguments
Modified: trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py
===================================================================
--- trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py 2007-07-09 15:38:26 UTC (rev 3153)
+++ trunk/Lib/sandbox/timeseries/plotlib/mpl_timeseries.py 2007-07-09 16:11:00 UTC (rev 3154)
@@ -14,6 +14,7 @@
import matplotlib
from matplotlib import pylab, rcParams
+from matplotlib import _pylab_helpers
from matplotlib.artist import setp
from matplotlib.axes import Subplot, PolarSubplot
from matplotlib.cbook import flatten
@@ -720,7 +721,9 @@
def tsplot(self,*parms,**kwargs):
"""Plots the data parsed in argument.
This command accepts the same keywords as `matplotlib.plot`."""
- #print "Parameters: %s - %i" % (parms, len(parms))
+# parms = tuple(list(parms) + kwargs.pop('series',None))
+# print "Parameters: %s - %i" % (parms, len(parms))
+# print "OPtions: %s - %i" % (kwargs, len(kwargs))
parms = self._check_plot_params(*parms)
self.legendlabels.append(kwargs.get('label',None))
Subplot.plot(self, *parms,**kwargs)
@@ -872,19 +875,32 @@
Figure.add_tsplot = add_tsplot
-def tsplot(*args, **kwargs):
+def tsplot(series, *args, **kwargs):
+ """Plots the series to the current TimeSeries subplot.
+ If the current plot is not a TimeSeriesPlot, a new TimeSeriesFigure is created."""
# allow callers to override the hold state by passing hold=True|False
b = pylab.ishold()
h = kwargs.pop('hold', None)
if h is not None:
pylab.hold(h)
+ # Get the current figure, or create one
+ figManager = _pylab_helpers.Gcf.get_active()
+ if figManager is not None :
+ fig = figManager.canvas.figure
+ if not isinstance(fig, TimeSeriesFigure):
+ fig = tsfigure(series=series)
+ else:
+ fig = tsfigure(series=series)
+ # Get the current axe, or create one
+ sub = fig._axstack()
+ if sub is None:
+ sub = fig.add_tsplot(111,series=series,**kwargs)
try:
- ret = pylab.gca().add_tsplot(*args, **kwargs)
+ ret = sub.tsplot(series, *args, **kwargs)
pylab.draw_if_interactive()
except:
pylab.hold(b)
raise
-
pylab.hold(b)
return ret
Modified: trunk/Lib/sandbox/timeseries/tseries.py
===================================================================
--- trunk/Lib/sandbox/timeseries/tseries.py 2007-07-09 15:38:26 UTC (rev 3153)
+++ trunk/Lib/sandbox/timeseries/tseries.py 2007-07-09 16:11:00 UTC (rev 3154)
@@ -1218,11 +1218,13 @@
def align_with(*series):
"""Aligns several TimeSeries to the first of the list, so that their
starting and ending dates match.
- Series are resized and filled with mased values accordingly.
+ Series are resized and filled with masked values accordingly.
"""
if len(series) < 2:
return series
dates = series[0]._dates[[0,-1]]
+ if len(series) == 2:
+ return adjust_endpoints(series[-1], dates[0], dates[-1])
return [adjust_endpoints(x, dates[0], dates[-1]) for x in series[1:]]
More information about the Scipy-svn
mailing list