def downsample(self, x, y, d, plotid=0, series=0): # x = self.get_data(plotid, series) # y = self.get_data(plotid, series, axis=1) self.set_data(downsample_1d(array(x), d), plotid, series) self.set_data(downsample_1d(array(y), d), plotid, series, axis=1) self.redraw()
def new_series(self, x=None, y=None, plotid=0, normalize=False, time_series=True, timescale=False, downsample=None, use_smooth=False, scale=None, ** kw): ''' ''' if not time_series: return super(TimeSeriesGraph, self).new_series(x=x, y=y, plotid=plotid, **kw) xd = x if x is not None: if isinstance(x[0], str): # convert the time stamp into seconds since the Epoch # Epoch = 12:00 am 1/1/1970 fmt = "%Y-%m-%d %H:%M:%S" args = x[0].split(' +') timefunc = lambda xi, fmt: time.mktime(time.strptime(xi, fmt)) if len(args) > 1: xd = [timefunc(xi.split(' +')[0], fmt) + float(xi.split(' +')[1]) / 1000.0 for xi in x] else: fmt = '%a %b %d %H:%M:%S %Y' xd = [timefunc(xi, fmt) for xi in x] if downsample: xd = downsample_1d(x, downsample) y = downsample_1d(y, downsample) if use_smooth: y = smooth(y) if xd is not None: xd = array(xd) if normalize: xd = xd - xd[0] if scale: xd = xd * scale plot, names, rd = self._series_factory(xd, y, plotid=plotid, **kw) if 'type' in rd: if rd['type'] == 'line_scatter': plot.plot(names, type='scatter', marker_size=2, marker='circle') rd['type'] = 'line' plota = plot.plot(names, **rd)[0] # plota.unified_draw = True # plota.use_downsampling = True # if the plot is not visible dont remove the underlays if plota.visible: self._set_bottom_axis(plota, plot, plotid, timescale=timescale) return plota, plot