def stack(x, y=None, z=None, name=None): '''Plot all of the given 1D y datasets against corresponding x as a 3D stack with optional z coordinates in the named view Arguments: x -- optional dataset or list of datasets for x-axis y -- dataset or list of datasets z -- optional dataset for z-axis name -- name of plot view to use (if None, use default name) ''' if not name: name = _PVNAME if not y: y = _toList(x) l = 0 for d in y: if d.size > l: l = d.size x = [ _core.arange(l) ] if z is None: _plot_stack(name, _toList(x), _toList(y)) else: _plot_stack(name, _toList(x), _toList(y), z)
def _parselinearg(x, y, title, name): '''x and y can be lists of arrays, tuples or single-item dicts (each tuple comprises an array and label) (each dict comprises an axis name (or tuple of axis name/position) and array (or array/label tuple)) ''' if y is None: if isinstance(x, (dict, tuple)): yl = [x] else: yl = _toList(x) x = None elif isinstance(y, (dict, tuple)): yl = [y] else: yl = _toList(y) if x is None: xl = None else: if isinstance(x, dict): xl = [x] else: xl = _toList(x) if len(xl) == 1: x = xl[0] if type(x) is _types.DictType: # has axis name x = x.values()[0] xLength = x.shape[0] for i in yl: if type(i) is _types.DictType: # has axis name i = i.values()[0] if type(i) is _types.ListType or type( i) is _types.TupleType: # has y dataset labelling i = i[0] if xLength != i.shape[0]: raise AttributeError( "length of y does not match the length of x") elif len(xl) != len(yl): raise ValueError( "number of x datasets should be equal to number of y datasets") else: for n in range(len(xl)): i = xl[n] j = yl[n] if type(i) is _types.DictType: # has axis name i = i.values()[0] if type(j) is _types.DictType: # has axis name j = j.values()[0] if type(j) is _types.ListType or type( j) is _types.TupleType: # has y dataset labelling j = j[0] if i is None: i = _core.arange(j.size, dtype=_core.int) i.shape = j.shape xl[n] = i elif i.shape[0] != j.shape[0]: raise AttributeError( "length of y does not match the length of x") return name, title, xl, yl
def updatestack(x, y=None, z=None, name=None): '''Update existing 3D line stack by changing displayed y dataset (or list of datasets), optionally against any given x dataset with optional z coordinates in the named view Arguments: x -- optional dataset or list of datasets for x-axis y -- dataset or list of datasets z -- optional dataset for z-axis name -- name of plot view to use (if None, use default name) ''' if name is None: name = _PVNAME if not y: y = _toList(x) l = 0 for d in y: if d.size > l: l = d.size x = [ _core.arange(l) ] _plot_updatestack(name, _toList(x), _toList(y), z)
def addstack(x, y=None, z=None, name=None): '''Add line(s) to existing stack plot, optionally against any given x datasets with optional z coordinates in the named view Arguments: x -- optional dataset or list of datasets for x-axis y -- dataset or list of datasets z -- optional dataset for z-axis name -- name of plot view to use (if None, use default name) ''' if name is None: name = _PVNAME if not y: y = _toList(x) l = 0 for d in y: if d.size > l: l = d.size x = [ _core.arange(l) ] _plot_addstack(name, _toList(x), _toList(y), z)
def updatestack(x, y=None, z=None, name=None): '''Update existing 3D line stack by changing displayed y dataset (or list of datasets), optionally against any given x dataset with optional z coordinates in the named view Arguments: x -- optional dataset or list of datasets for x-axis y -- dataset or list of datasets z -- optional dataset for z-axis name -- name of plot view to use (if None, use default name) ''' if name is None: name = _PVNAME if not y: y = _toList(x) l = 0 for d in y: if d.size > l: l = d.size x = [_core.arange(l)] _plot_updatestack(name, _toList(x), _toList(y), z)
def addstack(x, y=None, z=None, name=None): '''Add line(s) to existing stack plot, optionally against any given x datasets with optional z coordinates in the named view Arguments: x -- optional dataset or list of datasets for x-axis y -- dataset or list of datasets z -- optional dataset for z-axis name -- name of plot view to use (if None, use default name) ''' if name is None: name = _PVNAME if not y: y = _toList(x) l = 0 for d in y: if d.size > l: l = d.size x = [_core.arange(l)] _plot_addstack(name, _toList(x), _toList(y), z)