def add_overlay(self, spectrum, show=True): x, y = spectrum.data color = calculate_color(len(self.overlays) + 1) self.overlays.append(pg.PlotDataItem(x, y, pen=pg.mkPen(color=color, width=1.5))) self.overlay_names.append(spectrum.name) self.overlay_show.append(True) if show: self.spectrum_plot.addItem(self.overlays[-1]) self.legend.addItem(self.overlays[-1], spectrum.name) self.update_graph_range() return color
def __init__(self, plot_item, legend_item, positions, intensities, name=None, baseline=0): self.plot_item = plot_item self.legend_item = legend_item self.visible = True self.line_items = [] self.line_visible = [] self.spectrum_x_range = [] self.index = PhasePlot.num_phases self.color = calculate_color(self.index + 9) self.pen = pg.mkPen(color=self.color, width=0.9, style=QtCore.Qt.SolidLine) self.ref_legend_line = pg.PlotDataItem(pen=self.pen) self.name = '' PhasePlot.num_phases += 1 self.create_items(positions, intensities, name, baseline)