def add_time_series(self, time_series, configs=None): seen = set() x_values = [] labels = [] items_with_label = [] for i, ts in enumerate(time_series): # we do not plot duplicates, which might happen if multiple lines in the # table explorer are sellected ! if ts.uniqueId() in seen: continue seen.add(ts.uniqueId()) config = None if configs is not None: config = configs[i] if config is None: config = dict(color=getColor(i)) title = ts.label for j, item in enumerate(ts.for_plotting()): lconfig = config.copy() if len(item) == 2: x, y = item else: x, y, special_config = item lconfig.update(special_config) x = [ xi.toordinal() if isinstance(xi, datetime) else xi for xi in x ] x_values.extend(x) curve = make_unselectable_curve(x, y, title="<pre>%s</pre>" % title, **lconfig) self.plot.add_item(curve) if j == 0: labels.append(title) items_with_label.append(curve) x_values = sorted(set(x_values)) self.plot.set_x_values(x_values) self.plot.add_item(self.marker) self.plot.add_item(self.label) unique_labels = set(labels) self._add_legend(unique_labels, items_with_label)
def plot_spectra(self, all_peaks, labels): self.plot.del_all_items() self.plot.add_item(self.marker) self.plot.add_item(make.legend("TL")) self.plot.add_item(self.label) for i, (peaks, label) in enumerate(zip(all_peaks, labels)): config = dict(color=getColor(i)) curve = make_unselectable_curve([], [], title=label, curvestyle="Sticks", **config) curve.set_data(peaks[:, 0], peaks[:, 1]) self.plot.add_item(curve) self.plot.resample_config = [] self.plot.add_item(self.line) if len(all_peaks): self.plot.all_peaks = np.vstack(all_peaks) else: self.plot.all_peaks = np.zeros((0, 2))
def add_time_series(self, time_series, configs=None): seen = set() x_values = [] labels = [] items_with_label = [] for i, ts in enumerate(time_series): # we do not plot duplicates, which might happen if multiple lines in the # table explorer are sellected ! if ts.uniqueId() in seen: continue seen.add(ts.uniqueId()) config = None if configs is not None: config = configs[i] if config is None: config = dict(color=getColor(i)) title = ts.label for j, item in enumerate(ts.for_plotting()): lconfig = config.copy() if len(item) == 2: x, y = item else: x, y, special_config = item lconfig.update(special_config) x = [xi.toordinal() if isinstance(xi, datetime) else xi for xi in x] x_values.extend(x) curve = make_unselectable_curve(x, y, title="<pre>%s</pre>" % title, **lconfig) self.plot.add_item(curve) if j == 0: labels.append(title) items_with_label.append(curve) x_values = sorted(set(x_values)) self.plot.set_x_values(x_values) self.plot.add_item(self.marker) self.plot.add_item(self.label) unique_labels = set(labels) self._add_legend(unique_labels, items_with_label)
def default(i): return dict(color=getColor(i))