Added default plot_args and plot_args_children to WafoData

master
Per.Andreas.Brodtkorb 15 years ago
parent e2793d38c7
commit 4a8332d3a4

@ -62,10 +62,13 @@ class LevelCrossings(WafoData):
''' '''
def __init__(self, *args, **kwds): def __init__(self, *args, **kwds):
super(LevelCrossings, self).__init__(*args, **kwds) options = dict(title='Level crossing spectrum',
self.labels.title = 'Level crossing spectrum' xlab='Levels', ylab='Count',
self.labels.xlab = 'Levels' plot_args=['b'],
self.labels.ylab = 'Count' plot_args_children=['r--'],)
options.update(**kwds)
super(LevelCrossings, self).__init__(*args, **options)
self.stdev = kwds.get('stdev', None) self.stdev = kwds.get('stdev', None)
self.mean = kwds.get('mean', None) self.mean = kwds.get('mean', None)
self.setplotter(plotmethod='step') self.setplotter(plotmethod='step')
@ -448,14 +451,15 @@ class CyclePairs(WafoData):
''' '''
def __init__(self, *args, **kwds): def __init__(self, *args, **kwds):
super(CyclePairs, self).__init__(*args, **kwds)
self.type_ = kwds.get('type_', 'max2min') self.type_ = kwds.get('type_', 'max2min')
self.stdev = kwds.get('stdev', None) self.stdev = kwds.get('stdev', None)
self.mean = kwds.get('mean', None) self.mean = kwds.get('mean', None)
self.labels.title = self.type_ + ' cycle pairs' options = dict(title=self.type_ + ' cycle pairs',
self.labels.xlab = 'min' xlab='min', ylab='max',
self.labels.ylab = 'max' plot_args=['b.'])
options.update(**kwds)
super(CyclePairs, self).__init__(*args, **options)
def amplitudes(self): def amplitudes(self):
return (self.data - self.args) / 2. return (self.data - self.args) / 2.
@ -639,7 +643,7 @@ class TurningPoints(WafoData):
>>> ts = wafo.objects.mat2timeseries(x) >>> ts = wafo.objects.mat2timeseries(x)
>>> tp = ts.turning_points() >>> tp = ts.turning_points()
>>> mM = tp.cycle_pairs() >>> mM = tp.cycle_pairs()
>>> h = mM.plot('.') >>> h = mM.plot('x')
See also See also
@ -663,7 +667,6 @@ class TurningPoints(WafoData):
type_ = 'max2min' type_ = 'max2min'
M = self.data[iM:-1:2] M = self.data[iM:-1:2]
m = self.data[iM + 1::2] m = self.data[iM + 1::2]
return CyclePairs(M, m, type=type_) return CyclePairs(M, m, type=type_)
def mat2timeseries(x): def mat2timeseries(x):

@ -54,7 +54,7 @@ class WafoData(object):
Plot with confidence interval Plot with confidence interval
>>> d3 = WafoData(np.sin(x),x) >>> d3 = WafoData(np.sin(x),x)
>>> d3.children = [WafoData(np.vstack([np.sin(x)*0.9, np.sin(x)*1.2]).T,x)] >>> d3.children = [WafoData(np.vstack([np.sin(x)*0.9, np.sin(x)*1.2]).T,x)]
>>> d3.children_args=[':r'] >>> d3.plot_args_children=[':r']
>>> h = d3.plot() >>> h = d3.plot()
See also See also
@ -68,7 +68,9 @@ class WafoData(object):
self.date = now() self.date = now()
self.plotter = None self.plotter = None
self.children = None self.children = None
self.children_args = [] self.plot_args_children = kwds.get('plot_args_children',[])
self.plot_args = kwds.get('plot_args',[])
self.labels = AxisLabels(**kwds) self.labels = AxisLabels(**kwds)
self.setplotter() self.setplotter()
@ -77,15 +79,15 @@ class WafoData(object):
if self.children != None: if self.children != None:
plotbackend.hold('on') plotbackend.hold('on')
tmp = [] tmp = []
child_args = args + tuple(self.children_args) child_args = args + tuple(self.plot_args_children)
for child in self.children: for child in self.children:
tmp1 = child.plot(*child_args, **kwds) tmp1 = child.plot(*child_args, **kwds)
if tmp1 != None: if tmp1 != None:
tmp.append(tmp1) tmp.append(tmp1)
if len(tmp) == 0: if len(tmp) == 0:
tmp = None tmp = None
main_args = args + tuple(self.plot_args)
tmp2 = self.plotter.plot(self, *args, **kwds) tmp2 = self.plotter.plot(self, *main_args, **kwds)
return tmp2, tmp return tmp2, tmp
def show(self): def show(self):

Loading…
Cancel
Save