def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- from numpy import linspace, sin x = linspace(-10, 10, 200) dy = x / 100.0 y = sin(sin(sin(x))) x2 = linspace(-10, 10, 20) y2 = sin(sin(sin(x2))) plot( [ make.curve(x, y, color="b"), make.label( "Relative position <b>outside</b>", (x[0], y[0]), (-10, -10), "BR" ), ], [ make.curve(x2, y2, color="g"), ], [ make.curve(x, sin(2 * y), color="r"), make.label("Relative position <i>inside</i>", (x[0], y[0]), (10, 10), "TL"), ], [ make.merror(x, y / 2, dy), make.label("Absolute position", "R", (0, 0), "R"), make.legend("TR"), ], )
def setup_widget(self): # ---Create the plot widget: x = self.x y = self.y self.plot = CurvePlot(self) self.curve_item = make.curve([], [], color="b") self.plot.add_item(self.curve_item) self.plot.set_antialiasing(True) width = x[-1] - x[0] self.intrange = make.range(x[0] + 0.4 * width, x[-1] - 0.4 * width) self.plot.add_item(self.intrange) self.lbgrange = make.range(x[0] + 0.3 * width, x[-1] - 0.65 * width) self.plot.add_item(self.lbgrange) self.lbgrange.pen = Qt.QPen(Qt.QColor("blue")) self.lbgrange.brush = Qt.QBrush(Qt.QColor(0, 0, 120, 100)) self.rbgrange = make.range(x[0] + 0.7 * width, x[-1] - 0.1 * width) self.rbgrange.pen = Qt.QPen(Qt.QColor("blue")) self.rbgrange.brush = Qt.QBrush(Qt.QColor(0, 0, 120, 100)) self.label1 = make.label(r"", "TR", (0, 0), "TR") self.plot.add_item(self.rbgrange) self.bg_item = make.curve([], [], color="r") self.plot.add_item(self.bg_item) self.fit_bg() self.plot.add_item(self.label1) self.connect(self.plot, SIG_RANGE_CHANGED, self.fit_bg) # --- vlayout = QVBoxLayout() vlayout.addWidget(self.plot) self.setLayout(vlayout) self.update_curve()
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- from numpy import linspace, sin mydescr = N.dtype([('Zeit', 'float'), ('T1', 'float'), ('T2', 'float'), ('T3', 'float'),('T4', 'float'),('T5', 'float'), ('T6', 'float'), ('T7', 'float'),('T8', 'float')]) myrecarray = read_array('test.ASC', mydescr) x = myrecarray['Zeit'] y = savitzky_golay(myrecarray['T1'], window_size=131, order=3) y2 = savitzky_golay(myrecarray['T2'], window_size=131, order=3) y3 = savitzky_golay(myrecarray['T3'], window_size=131, order=3) #x = linspace(-10, 10, 200) #dy = x/100. #y = sin(sin(sin(x))) #x2 = linspace(-10, 10, 20) #y2 = sin(sin(sin(x2))) plot(make.curve(x, y, color="b"), make.curve(x, y2, color="g",), make.curve(x, y3, color="r"), make.label("Relative position <b>outside</b>", (x[0], y[0]), (-10, -10), "BR"), make.label("Relative position <i>inside</i>", (x[0], y[0]), (10, 10), "TL"), make.label("Absolute position", "R", (0,0), "R"), make.legend("TR"), )
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- # from numpy import linspace, sin #x = linspace(-10, 10, 200) start_rec = 819 num_rec = 10000 x = range(start_rec, start_rec + num_rec) vname, y = loadBinData('ATOLOG_01R_1.atp', start_rec, num_rec) plot(make.curve(x, y[0], title=vname[0], color="b"), make.curve(x, y[1], title=vname[1], color="g"), #make.curve(x, sin(2*y), color="r"), #make.merror(x, y/2, dy), #make.label("Relative position <b>outside</b>", # (x[0], y[0]), (-10, -10), "BR"), #make.label("Relative position <i>inside</i>", # (x[0], y[0]), (10, 10), "TL"), #make.label("Absolute position", "R", (0,0), "R"), make.legend("TR"), #make.marker(position=(5., .8), label_cb=lambda x, y: u"A = %.2f" % x, # markerstyle="|", movable=False) )
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- from numpy import linspace, sin x = linspace(-10, 10, 200) dy = x / 100.0 y = sin(sin(sin(x))) x2 = linspace(-10, 10, 20) y2 = sin(sin(sin(x2))) curve2 = make.curve(x2, y2, color="g", curvestyle="Sticks") curve2.setTitle("toto") plot( make.curve(x, y, color="b"), curve2, make.curve(x, sin(2 * y), color="r"), make.merror(x, y / 2, dy), make.label("Relative position <b>outside</b>", (x[0], y[0]), (-10, -10), "BR"), make.label("Relative position <i>inside</i>", (x[0], y[0]), (10, 10), "TL"), make.label("Absolute position", "R", (0, 0), "R"), make.legend("TR"), make.marker( position=(5.0, 0.8), label_cb=lambda x, y: "A = %.2f" % x, markerstyle="|", movable=False, ), )
def __init__(self, ui): self.collect_data_thread = Collect_data() self.Array = [] self.ui = ui self.count = 0 self.go_on = True # Set up guiqwt plot self.curve_item = make.curve([], [], color='b', marker="o") self.ui.curvewidget_keithley.plot.add_item(self.curve_item) self.ui.curvewidget_keithley.plot.set_antialiasing(True) self.ui.curvewidget_keithley.plot.set_titles( "Measurement and Plot Based on Array", "X-Axis", "Y-Axis") self.curve_ct_item = make.curve([], [], color='b', marker="o") self.ui.curvewidget_ct_keithley.plot.add_item(self.curve_ct_item) self.ui.curvewidget_ct_keithley.plot.set_antialiasing(True) self.ui.curvewidget_ct_keithley.plot.set_titles( "Current vs Time", "Time", "Current") self.curve_vt_item = make.curve([], [], color='b', marker="o") self.ui.curvewidget_vt_keithley.plot.add_item(self.curve_vt_item) self.ui.curvewidget_vt_keithley.plot.set_antialiasing(True) self.ui.curvewidget_vt_keithley.plot.set_titles( "Voltage vs Time", "Time", "Voltage")
def _split_plot_ver(channels, spikes, strong, fade, ref_units, time_unit, progress, max_offset, plot): """ Fill a plot with spikes vertically split by channel. Returns legend. """ offset = 0 * ref_units for c in channels: for u in spikes: color = helper.get_object_color(u) qcol = Qt.QColor(color) alpha = fade if fade > 0.0 else 1.0 alpha_step = 1.0 - fade if fade > 0.0 else -1.0 - fade alpha_step /= len(spikes[u]) if len(spikes[u]) == 1: alpha = 1.0 for s in spikes[u]: if s.waveform is None or s.sampling_rate is None: raise SpykeException('Cannot create waveform plot: ' 'At least one spike has no ' 'waveform or sampling rate!') x = (sp.arange(s.waveform.shape[0]) / s.sampling_rate).rescale(time_unit) curve = make.curve(x, s.waveform[:, c].rescale(ref_units) + offset, u.name, color=color) qcol.setAlphaF(alpha) curve.setPen(Qt.QPen(qcol)) alpha += alpha_step plot.add_item(curve) progress.step() for u in strong: color = helper.get_object_color(u) for s in strong[u]: x = (sp.arange(s.waveform.shape[0]) / s.sampling_rate).rescale(time_unit) outline = make.curve(x, s.waveform[:, c].rescale(ref_units) + offset, color='#000000', linewidth=4) curve = make.curve(x, s.waveform[:, c].rescale(ref_units) + offset, color=color, linewidth=2) plot.add_item(outline) plot.add_item(curve) progress.step() offset += max_offset l = _add_legend(plot, spikes, strong) return l
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- from numpy import linspace, sin x = linspace(-10, 10, 200) dy = x / 100.0 y = sin(sin(sin(x))) x2 = linspace(-10, 10, 20) y2 = sin(sin(sin(x2))) curve2 = make.curve(x2, y2, color="g", curvestyle="Sticks") curve2.setTitle("toto") plot( make.curve(x, y, color="b"), curve2, make.curve(x, sin(2 * y), color="r"), make.merror(x, y / 2, dy), make.label("Relative position <b>outside</b>", (x[0], y[0]), (-10, -10), "BR"), make.label("Relative position <i>inside</i>", (x[0], y[0]), (10, 10), "TL"), make.label("Absolute position", "R", (0, 0), "R"), make.legend("TR"), make.marker(position=(5.0, 0.8), label_cb=lambda x, y: "A = %.2f" % x, markerstyle="|", movable=False), )
def _correlogram_plot(win, trains, bin_size, cut_off, border_correction, progress, unit): """ Fill a plot window with correlograms. """ correlograms, bins = correlogram(trains, bin_size, cut_off, border_correction, unit, progress) x = bins[:-1] + bin_size / 2 crlgs = [] indices = correlograms.keys() for i1 in xrange(len(indices)): for i2 in xrange(i1, len(indices)): crlgs.append((correlograms[indices[i1]][indices[i2]], indices[i1], indices[i2])) for i, c in enumerate(crlgs): legend_items = [] pW = BaseCurveWidget(win) plot = pW.plot plot.set_antialiasing(True) plot.add_item(make.curve(x, c[0])) # Create legend color = helper.get_object_color(c[1]) color_curve = make.curve([], [], c[1].name, color, 'NoPen', linewidth=1, marker='Rect', markerfacecolor=color, markeredgecolor=color) legend_items.append(color_curve) plot.add_item(color_curve) if c[1] != c[2]: color = helper.get_object_color(c[2]) color_curve = make.curve([], [], c[2].name, color, 'NoPen', linewidth=1, marker='Rect', markerfacecolor=color, markeredgecolor=color) legend_items.append(color_curve) plot.add_item(color_curve) plot.add_item(make.legend(restrict_items=legend_items)) columns = max(2, len(indices) - 3) if i >= len(correlograms) - columns: plot.set_axis_title(BasePlot.X_BOTTOM, 'Time') plot.set_axis_unit(BasePlot.X_BOTTOM, unit.dimensionality.string) if i % columns == 0: plot.set_axis_title(BasePlot.Y_LEFT, 'Correlation') plot.set_axis_unit(BasePlot.Y_LEFT, 'count/segment') win.add_plot_widget(pW, i, column=i%columns) win.add_x_synchronization_option(True, range(len(correlograms))) win.add_y_synchronization_option(False, range(len(correlograms))) win.add_custom_curve_tools() progress.done() win.show() return True
def _split_plot_ver(channels, spikes, strong, fade, ref_units, time_unit, progress, max_offset, plot): """ Fill a plot with spikes vertically split by channel. Returns legend. """ offset = 0 * ref_units for c in channels: for u in spikes: color = helper.get_object_color(u) qcol = Qt.QColor(color) alpha = fade if fade > 0.0 else 1.0 alpha_step = 1.0 - fade if fade > 0.0 else -1.0 - fade alpha_step /= len(spikes[u]) if len(spikes[u]) == 1: alpha = 1.0 for s in spikes[u]: if s.waveform is None or s.sampling_rate is None: raise SpykeException('Cannot create waveform plot: ' 'At least one spike has no ' 'waveform or sampling rate!') x = (sp.arange(s.waveform.shape[0]) / s.sampling_rate).rescale(time_unit) curve = make.curve( x, s.waveform[:, c].rescale(ref_units) + offset, u.name, color=color) qcol.setAlphaF(alpha) curve.setPen(Qt.QPen(qcol)) alpha += alpha_step plot.add_item(curve) progress.step() for u in strong: color = helper.get_object_color(u) for s in strong[u]: x = (sp.arange(s.waveform.shape[0]) / s.sampling_rate).rescale(time_unit) outline = make.curve( x, s.waveform[:, c].rescale(ref_units) + offset, color='#000000', linewidth=4) curve = make.curve( x, s.waveform[:, c].rescale(ref_units) + offset, color=color, linewidth=2) plot.add_item(outline) plot.add_item(curve) progress.step() offset += max_offset l = _add_legend(plot, spikes, strong) return l
def setup_widget(self): self.plot = CurvePlot(self) self.data_cut = make.curve(self.xdata, self.ydata) self.data_fit = make.curve(self.xfit, self.yfit) self.plot.add_item(self.data_cut) self.plot.add_item(self.data_fit) vlayout = QVBoxLayout() vlayout.addWidget(self.plot) self.setLayout(vlayout)
def fullRefresh(self): """ plot refresh """ for plot in self.plots: plot.del_all_items(except_grid=False) self.signal_curves = [] if self.analogsignals: for i, analist in enumerate(self.analogsignals): self.signal_curves.append([]) for p, ana in enumerate(analist): curve = make.curve([], [], color='b') self.plots[p].add_item(curve) self.signal_curves[-1].append(curve) self.spike_curves = [] self.selectedspikes_curves = [] if self.spiketrains: for p in range(self.nplot): self.spike_curves.append([]) for i, spiketrains2 in enumerate(self.spiketrains): self.spike_curves[p].append([]) for j, spiketrain in enumerate(spiketrains2): if type(spiketrain.color) is str: color = QColor(spiketrain.color) elif type(spiketrain.color) is tuple: color = QColor( *tuple([c * 255 for c in spiketrain.color])) else: color = QColor('red') curve = make.curve([], [], markerfacecolor=color, marker='o', linestyle='', markersize=7) self.plots[p].add_item(curve) self.spike_curves[p][i].append(curve) for p in range(self.nplot): self.selectedspikes_curves.append([]) for i in range(len(self.analogsignals)): curve = make.curve([], [], markerfacecolor='m', marker='o', linestyle='', markersize=8) #, alpha = .3) self.selectedspikes_curves[p].append(curve) self.plots[p].add_item(curve) self.refresh()
def show_data(self, x, y, flag=None): plot = self.imagewidget.plot if self.item is not None: self.item.set_data(x, y) else: self.item = make.curve(x, y, color='blue') plot.add_item(self.item, z=0) if flag is not None: if self.flagitem is not None: self.flagitem.set_data(x, flag * y) else: self.flagitem = make.curve(x, flag * y, color='green') plot.add_item(self.flagitem, z=0) plot.replot()
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- from numpy import linspace, sin import labrad cx=labrad.connect('lab-rat', password='******') ai=cx.agilent_pna_with_vxi_11 ai.select_device(0) testscan=ai.freq_sweep() len(testscan) xx=testscan[0].asarray yytemp=testscan[1].asarray[0] yy=np.square(abs(yytemp)) # x = linspace(-10, 10, 200) # dy = x/100. # y = sin(sin(sin(x))) # x2 = linspace(-10, 10, 20) # y2 = sin(sin(sin(x2))) # plot(make.curve(x, y, color="b"), # make.curve(x2, y2, color="g", curvestyle="Sticks"), # make.curve(x, sin(2*y), color="r"), # make.merror(x, y/2, dy), # make.label("Relative position <b>outside</b>", # (x[0], y[0]), (-10, -10), "BR"), # make.label("Relative position <i>inside</i>", # (x[0], y[0]), (10, 10), "TL"), # make.label("Absolute position", "R", (0,0), "R"), # make.legend("TR"), # make.marker(position=(5., .8), label_cb=lambda x, y: u"A = %.2f" % x, # markerstyle="|", movable=False) # ) plot(make.curve(xx*1e-9, 10*np.log10(yy), color="b"), make.curve(xx*2e-9, 10*np.log10(yy), color="g"), # make.curve(x, sin(2*y), color="r"), # make.merror(x, y/2, dy), make.label("PNA SCAN<b>test</b>", (xx[0], yy[0]), (-10, -10), "BR"), make.label("PNA SCAN<b>test 2X</b>", (xx[0], yy[0]), (-10, -10), "BR"), # make.label("Relative position <i>inside</i>", # (x[0], y[0]), (10, 10), "TL"), # make.label("Absolute position", "R", (0,0), "R"), make.legend("TR"), # make.marker(position=(5., .8), label_cb=lambda xx, yy: u"A = %.2f" % xx, # markerstyle="|", movable=False) )
def __init__(self, parent, toolbar): QSplitter.__init__(self, parent) # QTabWidget.__init__(self, parent) self.setContentsMargins(10, 10, 10, 10) self.setOrientation(Qt.Vertical) linelistwithproperties = LineListWithProperties(self) # self.addWidget(linelistwithproperties) self.lineList = linelistwithproperties.lineList self.connect(self.lineList, SIGNAL("currentRowChanged(int)"), self.current_item_changed) self.connect(self.lineList, SIGNAL("itemSelectionChanged()"), self.selection_changed) self.curveProperties = linelistwithproperties.properties self.connect(self.curveProperties, SIGNAL("apply_button_clicked()"), self.curve_properties_changed) self.curvewidget = CurveWidget(self) self.curvewidget.register_all_curve_tools() self.curve_item = make.curve([], [], color='b') self.peak_item = make.curve([],[], markerfacecolor = 'r', marker = 'o', curvestyle="NoCurve")#, alpha = 0.75) self.curvewidget.plot.add_item(self.curve_item) self.curvewidget.plot.add_item(self.peak_item) self.curvewidget.plot.set_antialiasing(True) self.addWidget(self.curvewidget) self.lines = [] # List of ImageParam instances self.peaks = [] vSplitter = QSplitter() vSplitter.setOrientation(Qt.Vertical) daqParamProperties = DAQParamsProperties(self) self.daqProperties = daqParamProperties.properties self.connect(self.daqProperties, SIGNAL("apply_button_clicked()"), self.daq_properties_changed) # daqButton = QPushButton("Upload DAQ Params") vSplitter.addWidget(daqParamProperties) # vSplitter.addWidget(daqButton) tabWidget = QTabWidget() tab1 = tabWidget.addTab(linelistwithproperties, "Curve Params") tab2 = tabWidget.addTab(vSplitter, "DAQ Params") self.addWidget(tabWidget) self.setStretchFactor(0, 0) self.setStretchFactor(1, 1) self.setHandleWidth(10) self.setSizes([1, 2])
def show_data(self, label): data = self.raw_data[label]['data'] xaxis = self.raw_data['Latest']['freqs'] print('xmin', np.min(xaxis), np.max(xaxis)) self.dshape = data.shape[0] vals = np.log10(data.shape[0]) if vals > 4: fact = 10**int(vals - 4) n = int(data.shape[0] / fact) print('Factor', fact, 'N', n) s = data[0:n * fact].reshape(n, fact) data = np.mean(s, axis=1) s = xaxis[0:n * fact].reshape(n, fact) xaxis = np.mean(s, axis=1) print('Min', np.min(data), 'Max', np.max(data), data.shape) print('dshape', self.dshape) if label in list(self.item.keys()): if self.do_log: self.item[label].set_data( xaxis, self.cal_slope * data + self.cal_icept) else: self.item[label].set_data(xaxis, data) else: if self.do_log: self.item[label] = make.curve( xaxis, self.cal_slope * data + self.cal_icept, color=self.colours[len(self.item) % len(self.colours)], title=label) else: self.item[label] = make.curve( xaxis, data, color=self.colours[len(self.item) % len(self.colours)], title=label) self.curvewidget.plot.add_item(self.item[label]) self.curvewidget.plot.set_antialiasing(True) if self.legend is None: self.legend = make.legend("TR") self.curvewidget.plot.add_item(self.legend) self.item[label].plot().replot()
def refresh(self, slider_value=None): """Refresh Fit Tool dialog box""" # Update button states enable = self.x is not None and self.y is not None \ and self.x.size > 0 and self.y.size > 0 \ and self.fitfunc is not None and self.fitparams is not None \ and len(self.fitparams) > 0 for btn in self.button_list: btn.setEnabled(enable) if not enable: # Fit widget is not yet configured return fitargs, fitkwargs = self.get_fitfunc_arguments() yfit = self.fitfunc(self.x, [p.value for p in self.fitparams], *fitargs, **fitkwargs) plot = self.get_plot() if self.legend is None: self.legend = make.legend(anchor=self.legend_anchor) plot.add_item(self.legend) if self.xrange is None: self.xrange = make.range(0., 1.) plot.add_item(self.xrange) self.xrange.set_range(self.autofit_prm.xmin, self.autofit_prm.xmax) self.xrange.setVisible(self.show_xrange) if self.data_curve is None: self.data_curve = make.curve([], [], _("Data"), color="b", linewidth=2) plot.add_item(self.data_curve) self.data_curve.set_data(self.x, self.y) if self.fit_curve is None: self.fit_curve = make.curve([], [], _("Fit"), color="r", linewidth=2) plot.add_item(self.fit_curve) self.fit_curve.set_data(self.x, yfit) plot.replot() plot.disable_autoscale()
def setup_plot_widget(self): self.plot_widget = plot.CurveWidget(self, 'curve graph', show_itemlist=False) self.plot_widget.plot.set_antialiasing(True) #self.plot_widget.register_all_curve_tools() #self.plot_widget.add_tool(guiqwt.tools.AntiAliasingTool) #---guiqwt plot manager self.manager = plot.PlotManager(self) #---Register plot to manager self.manager.add_plot(self.plot_widget.plot) #--- #---Add toolbar and register manager tools #toolbar = self.parent().addToolBar("tools") self.toolbar = QtGui.QToolBar("plot tools", self) self.autoscale = NamedCheckBox(self, 'autoscale') self.autoscale.checked.connect(self.plot_widget.plot.do_autoscale) self.toolbar.addWidget(self.autoscale) self.manager.add_toolbar(self.toolbar, id(self.toolbar)) self.curve_item = make.curve([], [], color='b') self.plot_widget.plot.add_item(self.curve_item) self.manager.register_all_curve_tools() self.manager.add_tool(CutSignalTool) #============================= # for tools such as CurveStatsTool to work # the curve needs to have been selected at least once. self.plot_widget.plot.set_active_item(self.curve_item) self.curve_item.unselect()
def plot(self, chromatograms, titles=None, configs=None, withmarker=False): """ do not forget to call replot() after calling this function ! """ allrts = set() self.widget.plot.del_all_items() # self.widget.plot.set_antialiasing(True) for i in range(len(chromatograms)): rts, chromatogram = chromatograms[i] config = None if configs is not None: config = configs[i] if config is None: config = dict(color=getColor(i)) if titles: title = titles[i] else: title = "" curve = make.curve(rts, chromatogram, title=title, **config) curve.__class__ = ModifiedCurveItem allrts.update(rts) self.widget.plot.add_item(curve) if withmarker: self.widget.plot.add_item(self.label) allrts = sorted(allrts) self.marker.rts = allrts self.marker.attach(self.widget.plot) self.widget.plot.add_item(self.marker) if titles is not None: self.widget.plot.add_item(make.legend("TL")) self.addRangeSelector(allrts)
def __init__(self): super(RealtimeDemo, self).__init__() self.setWindowTitle(u"Realtime Demo") self.data = {u"t": array("d")} for name in sum(PLOT_DEFINE, []): self.data[name] = array("d") self.curves = {} self.t = 0 vbox = QVBoxLayout() vbox.addWidget(self.setup_toolbar()) self.manager = PlotManager(self) self.plots = [] for i, define in enumerate(PLOT_DEFINE): plot = CurvePlot() plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(60) self.manager.add_plot(plot) self.plots.append(plot) plot.plot_id = id(plot) for j, curve_name in enumerate(define): curve = self.curves[curve_name] = make.curve([0], [0], color=COLORS[j], title=curve_name) plot.add_item(curve) plot.add_item(make.legend("BL")) vbox.addWidget(plot) self.manager.register_standard_tools() self.manager.get_default_tool().activate() self.manager.synchronize_axis(CurvePlot.X_BOTTOM, self.manager.plots.keys()) self.setLayout(vbox) self.startTimer(100)
def _add_spike_waveforms(plot, spikes, x_units, channel, offset, progress): for spike in spikes: if spike.waveform is None or not spike.sampling_rate: continue if channel < 0 or spike.waveform.shape[1] <= channel: continue color = helper.get_object_color(spike.unit) if spike.left_sweep: lsweep = spike.left_sweep else: lsweep = 0.0 * pq.ms start = (spike.time - lsweep).rescale(x_units) stop = (spike.waveform.shape[0] / spike.sampling_rate + spike.time - lsweep).rescale(x_units) spike_x = sp.arange( start, stop, (1.0 / spike.sampling_rate).rescale(x_units)) * x_units plot.add_item( make.curve(spike_x, spike.waveform[:, channel] + offset, color=color, linewidth=2)) progress.step()
def plot_thicknesses(self): llambda_min = 0. llambda_max = 2. for t, col in [(0.030, 'red'),(0.050,'green'),(0.100, 'black'),(0.200, 'blue')]: c = make.curve([llambda_min, llambda_max],[t, t], color=col, title='thickness=' + str(t)) self.get_plot().add_item(c)
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- from numpy import linspace, sin, trapz x = linspace(-10, 10, 1000) y = sin(sin(sin(x))) curve = make.curve(x, y, "ab", "b") range = make.range(-2, 2) disp0 = make.range_info_label(range, "BR", "x = %.1f ± %.1f cm", title="Range infos") disp1 = make.computation(range, "BL", "trapz=%g", curve, lambda x, y: trapz(y, x)) disp2 = make.computations( range, "TL", [ (curve, "min=%.5f", lambda x, y: y.min()), (curve, "max=%.5f", lambda x, y: y.max()), (curve, "avg=%.5f", lambda x, y: y.mean()), ], ) legend = make.legend("TR") plot(curve, range, disp0, disp1, disp2, legend)
def line_plot(self, dset, add_to_plot=False): self.msg("line plot") self.gui['plots_tabWidget'].setCurrentIndex(1) line_plot = self.gui['line_plot'] if not add_to_plot: line_plot.del_all_items() try: xdata = np.array(dset.dims[0][0]) except Exception as e: self.msg("Couldn't find x data") self.msg(e) xdata = np.arange(dset.shape[0]) try: xlab = dset.dims[0].label except: self.msg("Couldn't find x label") xlab = "" try: ylab = dset.name except AttributeError: ylab = "" curve_item = make.curve(x=xdata, y=np.array(dset)) line_plot.add_item(curve_item) line_plot.set_axis_unit(2, xlab) line_plot.set_axis_unit(0, ylab) line_plot.show() line_plot.do_autoscale()
def build_items(): x = np.linspace(-10, 10, 200) y = np.sin(np.sin(np.sin(x))) filename = osp.join(osp.dirname(__file__), "brain.png") items = [ make.curve(x, y, color="b"), make.image(filename=filename), make.trimage(filename=filename), make.maskedimage(filename=filename, colormap='gray', show_mask=True, xdata=[0, 40], ydata=[0, 50]), make.label("Relative position <b>outside</b>", (x[0], y[0]), (-10, -10), "BR"), make.label("Relative position <i>inside</i>", (x[0], y[0]), (10, 10), "TL"), make.label("Absolute position", "R", (0, 0), "R"), make.legend("TR"), make.rectangle(-3, -0.8, -0.5, -1., "rc1"), make.segment(-3, -0.8, -0.5, -1., "se1"), make.ellipse(-10, 0.0, 0, 0, "el1"), make.annotated_rectangle(0.5, 0.8, 3, 1., "rc1", "tutu"), make.annotated_segment(-1, -1, 1, 1., "rc1", "tutu"), Axes((0, 0), (1, 0), (0, 1)), PolygonShape( np.array([[150., 330.], [270., 520.], [470., 480.], [520., 360.], [460., 200.], [250., 240.]])), ] return items
def plot(self, chromatograms, titles=None, configs=None,\ withmarker=False): """ do not forget to call replot() after calling this function ! """ allrts = set() self.widget.plot.del_all_items() #self.widget.plot.set_antialiasing(True) for i in range(len(chromatograms)): rts, chromatogram = chromatograms[i] config = None if configs is not None: config = configs[i] if config is None: config = dict(color = getColor(i)) if titles: title = titles[i] else: title = "" curve = make.curve(rts, chromatogram, title=title, **config) curve.__class__ = ModifiedCurveItem allrts.update(rts) self.widget.plot.add_item(curve) if withmarker: self.widget.plot.add_item(self.label) allrts = sorted(allrts) self.marker.rts = allrts self.marker.attach(self.widget.plot) self.widget.plot.add_item(self.marker) if titles is not None: self.widget.plot.add_item(make.legend("TL")) self.addRangeSelector(allrts)
def __init__(self, main, ui): self.ui = ui self.update_visa() self.collectDataThread = CollectData() self.curve_item = make.curve([], [], color='b') self.ui.curvewidgetPlot.plot.add_item(self.curve_item) self.ui.curvewidgetPlot.plot.set_antialiasing(True) self.ui.curvewidgetPlot.plot.set_titles("Title", "X-Axis", "Y-Axis") self.ui.pushButtonStopRS.setEnabled(False) self.ui.pushButtonPauseRS.setEnabled(False) main.connect(self.ui.pushButtonSelectRS, SIGNAL("clicked()"), self.choose_visa) main.connect(self.ui.pushButtonUpdateRS, SIGNAL("clicked()"), self.update_visa) main.connect(self.ui.pushButtonSourceSelectRS, SIGNAL("clicked()"), self.choose_visa) main.connect(self.ui.pushButtonSourceUpdateRS, SIGNAL("clicked()"), self.update_visa) main.connect(self.ui.pushButtonStartRS, SIGNAL("clicked()"), self.start) main.connect(self.ui.pushButtonStopRS, SIGNAL("clicked()"), self.stop) main.connect(self.ui.pushButtonPauseRS, SIGNAL("clicked()"), self.collectDataThread.pause) main.connect(self.collectDataThread, SIGNAL("plot"), self.plotData) main.connect(self.collectDataThread, SIGNAL("stop"), self.stop)
def __init__(self, parent, ytitle="Y", inity=1000): # self.curve_vlf = make.curve( [ ], [ ], '(Curve Name)', QColor( 255, 0, 0 ), shade=0.5 ) # self.curve_lf = make.curve( [ ], [ ], '(Curve Name)', QColor( 0, 255, 0 ), shade=0.5 ) # self.curve_hf = make.curve( [ ], [ ], '(Curve Name)', QColor( 0, 0, 255 ), shade=0.5 ) self.psdcurve = make.curve( [ ], [ ], '(Curve Name)', QColor( 160, 160, 160 ), shade=0.2 ) def buildrect(x1, x2, filler): rect = RectangleShape(x1, 0., x2, inity) rect.brush.setStyle( Qt.SolidPattern ) rect.brush.setColor( filler ) rect.pen.setStyle( Qt.NoPen ) return rect self.dockwidget = myDockableWidget(parent, CurveWidget, toolbar=True ) # self.plot = self.curvewidget.get_plot() self.plot = self.dockwidget.widget.plot # self.plot.add_item( self.curve_vlf ) # self.plot.add_item( self.curve_lf ) # self.plot.add_item( self.curve_hf ) alpha = 100 self.plot.add_item( buildrect(0.,0.04, QColor(255,178,178,alpha)) ) self.plot.add_item( buildrect(0.04,0.15, QColor(178,178,255,alpha)) ) self.plot.add_item( buildrect(0.15,0.5, QColor(255,255,178,alpha)) ) self.plot.add_item( self.psdcurve ) self.plot.set_antialiasing( True ) self.plot.set_axis_title( QwtPlot.xBottom, 'Frequency' ) self.plot.set_axis_unit( QwtPlot.xBottom, 'Hz' ) self.plot.set_axis_title( QwtPlot.yLeft, ytitle ) self.plot.set_axis_unit( QwtPlot.yLeft, 's^2/Hz' ) #self.plot.setAxisScale(QwtPlot.xBottom, 0, 0.5) self.plot.set_axis_limits( QwtPlot.xBottom, 0, 0.5 )
def process(self): params = {} print(self.tableWidget.rowCount()) for i in range(self.tableWidget.rowCount()): a = self.tableWidget.item(i, 0) b = self.tableWidget.item(i, 1) params[str(a.text())] = int(b.text()) # print "params",params outpN = self.tableWidget.item(0, 0) #params = {"none": "none", "output_length": outpN} ''' if self.currentdata==[]: data = self.prc.preprocData(self.flowData, params) else: data = self.prc.preprocData(self.currentdata, params) ''' #self.dc.setCurrentDataFlowObject(data) #print data if params==[]: data = self.prc.preprocData(self.flowData, params) elif params!=[]: data = self.prc.preprocData(self.flowData, params) self.plot.del_all_items() print data print type(data) self.plot.add_item(make.curve(range(0, len(data)), data)) self.rangeSelection = make.range(-2, 2) disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm", title="Range infos") #self.plot.add_item(self.rangeSelection) #self.plot.add_item(disp0) self.plot.replot() #self.dc.setCurrentDataFlowObject(data) self.dc.preprocData = data self.currentdata = np.reshape(data, (-1, 1))
def __init__(self): super(RealtimeDemo, self).__init__() self.setWindowTitle(u"Realtime Demo") self.data = {u"t":array("d")} for name in sum(PLOT_DEFINE, []): self.data[name] = array("d") self.curves = {} self.t = 0 vbox = QVBoxLayout() vbox.addWidget(self.setup_toolbar()) self.manager = PlotManager(self) self.plots = [] for i, define in enumerate(PLOT_DEFINE): plot = CurvePlot() plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(60) self.manager.add_plot(plot) self.plots.append(plot) plot.plot_id = id(plot) for j, curve_name in enumerate(define): curve = self.curves[curve_name] = make.curve([0], [0], color=COLORS[j], title=curve_name) plot.add_item(curve) plot.add_item(make.legend("BL")) vbox.addWidget(plot) self.manager.register_standard_tools() self.manager.get_default_tool().activate() self.manager.synchronize_axis(CurvePlot.X_BOTTOM, self.manager.plots.keys()) self.setLayout(vbox) self.startTimer(100)
def add_spikes(plot, train, color='k', spike_width=1, spike_height=20000, y_offset=0, name='', units=None): """ Add all spikes from a spike train to a guiqwt plot as vertical lines. :param plot: The plot object. :type plot: :class:`guiqwt.baseplot.BasePlot` :param train: A spike train with the spike times to show. :type train: :class:`neo.core.SpikeTrain` :param str color: The color for the spikes. :param int spike_width: The width of the shown spikes in pixels. :param int spike_height: The height of the shown spikes in pixels. :param float y_offset: An offset for the drawing position on the y-axis. :param str name: The name of the spike train. :param Quantity units: The x-scale of the plot. If this is ``None``, the time unit of the events will be use. :returns: The plot item added for the spike train """ if units: train = train.rescale(units) spikes = make.curve( train, sp.zeros(len(train)) + y_offset, name, 'k', 'NoPen', linewidth=0, marker='Rect', markerfacecolor=color, markeredgecolor=color) s = spikes.symbol() s.setSize(spike_width - 1, spike_height) spikes.setSymbol(s) plot.add_item(spikes) return spikes
def testFcn(self): x = np.linspace(0, 100, 1000) y = (np.random.rand(len(x)) - 0.5).cumsum() curve = make.curve(x, y, "ab", "b") range = make.range(0, 5) disp2 = make.computations( range, "TL", [ (curve, "min=%.5f", lambda x, y: y.min()), (curve, "max=%.5f", lambda x, y: y.max()), (curve, "avg=%.5f", lambda x, y: y.mean()), ], ) legend = make.legend("TR") items = [curve, range, disp2, legend] win = CurveDialog(edit=False, toolbar=True, parent=self) plot = win.get_plot() for item in items: plot.add_item(item) win.show()
def build_items(): x = np.linspace(-10, 10, 200) y = np.sin(np.sin(np.sin(x))) filename = osp.join(osp.dirname(__file__), "brain.png") items = [ make.curve(x, y, color="b"), make.image(filename=filename), make.trimage(filename=filename), make.maskedimage(filename=filename, colormap='gray', show_mask=True, xdata=[0, 40], ydata=[0, 50]), make.label("Relative position <b>outside</b>", (x[0], y[0]), (-10, -10), "BR"), make.label("Relative position <i>inside</i>", (x[0], y[0]), (10, 10), "TL"), make.label("Absolute position", "R", (0, 0), "R"), make.legend("TR"), make.rectangle(-3, -0.8, -0.5, -1., "rc1"), make.segment(-3, -0.8, -0.5, -1., "se1"), make.ellipse(-10, 0.0, 0, 0, "el1"), make.annotated_rectangle(0.5, 0.8, 3, 1., "rc1", "tutu"), make.annotated_segment(-1, -1, 1, 1., "rc1", "tutu"), Axes( (0, 0), (1, 0), (0, 1) ), PolygonShape(np.array([[150., 330.], [270., 520.], [470., 480.], [520., 360.], [460., 200.], [250., 240.]])), ] return items
def plot(self, spectra, configs=None, titles=None): """ do not forget to call replot() after calling this function ! """ self.widget.plot.del_all_items() self.widget.plot.add_item(self.marker) if titles is not None: self.widget.plot.add_item(make.legend("TL")) self.widget.plot.add_item(self.label) allpeaks = [] for i in range(len(spectra)): peaks = spectra[i] allpeaks.append(peaks) config = configs[i] if configs is not None else None if config is None: config = dict(color = getColor(i)) if titles is not None: title = titles[i] else: title = u"" curve = make.curve([], [], title=title,\ curvestyle="Sticks", **config) curve.set_data(peaks[:, 0], peaks[:, 1]) curve.__class__ = ModifiedCurveItem self.widget.plot.add_item(curve) self.widget.plot.add_item(self.line) if len(allpeaks): self.widget.plot.all_peaks = np.vstack(allpeaks) else: self.widget.plot.all_peaks = np.zeros((0,2))
def addCurve(self, txy, color=None): (t, x, y) = txy curve = make.curve(x, y, t, color) self.plot.add_item(curve) if self.legend is None: self.legend = make.legend() self.plot.add_item(self.legend)
def plot_next(self, data): pl = self.ui.curve.get_plot() pl.del_all_items() c = [] if self.project.parameters.multiObjective: k = [] l = [] for i, j in sorted(data[1], key=lambda p: p[0]): k.append(i) l.append(j) self.resultslist[0].append(k) self.resultslist[1].append(l) for i in max(5, range(len(self.resultslist[0]))): st = self.styles(i, gen=len(self.resultslist[0])) c.append( make.curve(self.resultslist[0][-i - 1], self.resultslist[1][-i - 1], **st)) #c.append(make.curve(d[0],d[1],**st)) [self._plot(i) for i in reversed(c)] self._plot(make.legend("TR", restrict_items=c[:7])) else: self.resultslist[0].append(data[0]) for i in range(len(data[1])): self.resultslist[1][i].append(data[1][i]) if i == len(data[1]) - 1: st = self.styles(-1) else: st = self.styles(i) c.append( make.curve(self.resultslist[0], self.resultslist[1][i], **st)) [self._plot(i) for i in reversed(c)] lt = len(self.resultslist[1]) if lt > 4: its = c[:4] its.append(c[-1]) else: its = c[:lt + 1] self._plot(make.legend("TR", restrict_items=its)) self.zoom_the_plot(data) pl.replot()
def add_plot(self, iplt, irow, icol): widget = ImageWidget(self, "Plot #%d" % (iplt + 1)) widget.setMinimumSize(200, 150) xdata = np.linspace(-10, 10) ydata = np.sin(xdata + np.random.randint(0, 100) * 0.01 * np.pi) curve_item = make.curve(xdata, ydata, color="b") widget.plot.add_item(curve_item) self.layout().addWidget(widget, irow, icol, 1, 1)
def plot(self, curve): _plot = self.get_plot() _plot.add_item( make.curve(array(curve.get_plottable_data().index, dtype=float), curve.get_plottable_data().values, color=self.get_next_color(), title='[' + str(curve.id) + ']' + curve.name)) _plot.replot()
def loadData(self): self.trainingData = self.dataController.loadSampleData() import logic.dimreduce.paa as PAA p = PAA.paa() data = p.process(self.trainingData["PIR"][:], 100) r = np.array(range(len(data))).reshape(len(data), 1) s = np.array(data).reshape(len(data), 1) rs = np.hstack((s, s)) print rs import logic.featurex.kmeans as km k = km.kmeans() labels = k.process(rs, 2) print labels self.plot.add_item(make.curve(range(0, len(data)), data)) from guiqwt.styles import AnnotationParam i = 0 i_beg = 0 i_end = 0 while i < len(labels): cur = labels[i_end] if i < len(labels) - 1: if labels[i_end + 1] != cur: i_end = i from guiqwt.annotations import AnnotatedRectangle param = AnnotationParam() param.title = str(labels[int(i_beg)]) param.show_computations = False anno = AnnotatedRectangle(r[int(i_beg)], 0.5, r[int(i_end)], 0.2, param) # TODO: y axis scaling self.plot.add_item(anno) i_beg = i_end print "s1" else: i_end = i print "s2" print "s3" print "s4", i_end, len(labels) i += 1 # param = AnnotationParam() # param.title = "alright" # param.show_computations = False ##anno = AnnotatedRectangle(0., 1., 1.5, 0.5, param) # anno.set_style("plot", "shape/drag") # anno.set_style("shape/drag/fill/color", "white") # self.plot.add_item(anno) # self.rangeSelection = make.range(-2, 2) # disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm", # title="Range infos") # self.plot.add_item(self.rangeSelection) # self.plot.add_item(disp0) self.plot.replot()
def _split_plot_hor(channels, spikes, ref_units, time_unit, progress, plot): """ Fill a plot with spikeshorizontally split by channel. Returns legend. """ legend_items = [] offset = 0 * time_unit for c in channels: for u in spikes.keys(): first_wave = True color = helper.get_object_color(u) for s in spikes[u]: if s.waveform is None or s.sampling_rate is None: raise SpykeException( 'Cannot create waveform plot: ' 'At least one spike has no ' 'waveform or sampling rate!') x = (sp.arange(s.waveform.shape[0]) / s.sampling_rate).rescale(time_unit) curve = make.curve( x + offset, s.waveform[:, c].rescale(ref_units), u.name, color=color) if c == channels[0] and first_wave: legend_curve = make.curve( sp.array([0]), sp.array([0]), u.name, color=color, linewidth=2) legend_items.append(legend_curve) plot.add_item(legend_curve) first_wave = False plot.add_item(curve) progress.step() offset += x[-1] if c != channels[-1]: plot.add_item( make.marker((offset, 0), lambda x, y: '', movable=False, markerstyle='|', color='k', linestyle='-', linewidth=1)) l = make.legend(restrict_items=legend_items) plot.add_item(l) plot.set_axis_title(BasePlot.Y_LEFT, 'Voltage') plot.set_axis_unit( BasePlot.Y_LEFT, ref_units.dimensionality.string) return l
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- from numpy import linspace, sin import labrad cx=labrad.connect('lab-rat', password='******') ai=cx.agilent_pna ai.select_device(0) ai.s_parameters(['S21']) ai.averages(1000) ai.bandwidth(100) ai.power(0) ai.frequency_range(10.93e9, 11.03e9) ai.num_points(3201) testscan=ai.freq_sweep() print len(testscan) xx=testscan[0].asarray print xx yytemp=testscan[1].asarray[0] print yytemp yy=np.square(np.abs(yytemp)) # x = linspace(-10, 10, 200) # dy = x/100. # y = sin(sin(sin(x))) # x2 = linspace(-10, 10, 20) # y2 = sin(sin(sin(x2))) # plot(make.curve(x, y, color="b"), # make.curve(x2, y2, color="g", curvestyle="Sticks"), # make.curve(x, sin(2*y), color="r"), # make.merror(x, y/2, dy), # make.label("Relative position <b>outside</b>", # (x[0], y[0]), (-10, -10), "BR"), # make.label("Relative position <i>inside</i>", # (x[0], y[0]), (10, 10), "TL"), # make.label("Absolute position", "R", (0,0), "R"), # make.legend("TR"), # make.marker(position=(5., .8), label_cb=lambda x, y: u"A = %.2f" % x, # markerstyle="|", movable=False) # ) plot(make.curve(xx*1e-9, 10*np.log10(yy), color="b")#, # make.curve(xx*2e-9, 10*np.log10(yy), color="g"), # make.curve(x, sin(2*y), color="r"), # make.merror(x, y/2, dy), # make.label("PNA SCAN<b>test</b>", # (xx[0], yy[0]), (-10, -10), "BR"), # make.label("PNA SCAN<b>test 2X</b>", # (xx[0], yy[0]), (-10, -10), "BR"), # make.label("Relative position <i>inside</i>", # (x[0], y[0]), (10, 10), "TL"), # make.label("Absolute position", "R", (0,0), "R"), # make.legend("TR") # make.marker(position=(5., .8), label_cb=lambda xx, yy: u"A = %.2f" % xx, # markerstyle="|", movable=False) )
def loadData(self): self.trainingData = self.dataController.loadSampleData() self.plot.add_item(make.curve(range(0, self.trainingData.shape[0]), self.trainingData["PIR"][:])) self.rangeSelection = make.range(-2, 2) disp0 = make.range_info_label(self.rangeSelection, 'BR', u"x = %.1f +- %.1f cm", title="Range infos") self.plot.add_item(self.rangeSelection) self.plot.add_item(disp0) self.plot.replot()
def make_curves(styles, names): from guiqwt.builder import make curves = [] for s, n in zip(styles, names): c = make.curve([], [], color=s[0], linestyle=s[1:], title=n) curves.append(c) return curves
def __onPlotCurve(self): x = np.arange(1000) / 1000 self.curve1 = make.curve(x, np.sin(2 * np.pi * x), color="b", linestyle="DashLine") self.curve2 = make.curve(x, np.sin(2 * np.pi * x * 2), color="b", linestyle="DashLine") curve31 = make.curve(x, np.sin(2 * np.pi * x * 4), color="b", linestyle="DashLine") curve32 = make.curve(x, np.sin(2 * np.pi * x * 5), color="r", linestyle="DashLine") window = self._newPlotWindow("testCurvePlot") self.plot1 = window.addCurvePlot(title = "Sine1", curves = self.curve1, xlabel = "xlabel", ylabel = "ylabel") self.plot2 = window.addCurvePlot(self.curve2, title = "Sine2", position = [0, 1]) self.plot3 = window.addCurvePlot([curve31, curve32], title = "Sine3", pos = [1, 0, 1, 2]) manager = window.getManager() manager.synchronize_axis(self.plot1.X_BOTTOM, [id(self.plot1), id(self.plot2)]) manager.synchronize_axis(self.plot1.Y_LEFT, [id(self.plot1), id(self.plot2)]) window.show()
def plot_thicknesses(self): llambda_min = 0. llambda_max = 2. for t, col in [(0.030, 'red'), (0.050, 'green'), (0.100, 'black'), (0.200, 'blue')]: c = make.curve([llambda_min, llambda_max], [t, t], color=col, title='thickness=' + str(t)) self.get_plot().add_item(c)
def make_curveWidgets(self, curvewidget, color, markerColor, titles): curve_temp = make.curve([], [], color=color, marker="o", markerfacecolor=markerColor, markersize=5) curvewidget.plot.add_item(curve_temp) curvewidget.plot.set_antialiasing(True) curvewidget.plot.set_titles(titles[0], titles[1], titles[2]) return curve_temp
def plot_next(self, data): pl=self.ui.curve.get_plot() pl.del_all_items() c=[] if self.project.parameters.multiObjective: k=[] l=[] for i,j in sorted(data[1],key=lambda p: p[0]): k.append(i) l.append(j) self.resultslist[0].append(k) self.resultslist[1].append(l) for i in max(5,range(len(self.resultslist[0]))): st=self.styles(i, gen=len(self.resultslist[0])) c.append(make.curve(self.resultslist[0][-i-1],self.resultslist[1][-i-1],**st)) #c.append(make.curve(d[0],d[1],**st)) [self._plot(i) for i in reversed(c)] self._plot(make.legend("TR", restrict_items=c[:7])) else: self.resultslist[0].append(data[0]) for i in range(len(data[1])): self.resultslist[1][i].append(data[1][i]) if i==len(data[1])-1: st=self.styles(-1) else: st=self.styles(i) c.append(make.curve(self.resultslist[0], self.resultslist[1][i], **st)) [self._plot(i) for i in reversed(c)] lt=len(self.resultslist[1]) if lt > 4: its=c[:4] its.append(c[-1]) else: its=c[:lt+1] self._plot(make.legend("TR", restrict_items=its)) self.zoom_the_plot(data) pl.replot()
def fullRefresh(self): """ plot refresh """ for plot in self.plots: plot.del_all_items(except_grid=False) self.signal_curves = [ ] if self.analogsignals: for i, analist in enumerate(self.analogsignals): self.signal_curves.append([ ]) for p, ana in enumerate(analist): curve = make.curve([ ], [ ], color = 'b') self.plots[p].add_item(curve) self.signal_curves[-1].append(curve) self.spike_curves = [ ] self.selectedspikes_curves = [ ] if self.spiketrains: for p in range(self.nplot): self.spike_curves.append( [ ]) for i, spiketrains2 in enumerate(self.spiketrains): self.spike_curves[p].append([ ]) for j, spiketrain in enumerate(spiketrains2): if type(spiketrain.color) is str: color = QColor(spiketrain.color) elif type(spiketrain.color) is tuple: color = QColor( *tuple([c*255 for c in spiketrain.color]) ) else: color = QColor( 'red') curve = make.curve([ ], [ ], markerfacecolor= color,marker = 'o' , linestyle = '', markersize = 7) self.plots[p].add_item(curve) self.spike_curves[p][i].append( curve ) for p in range(self.nplot): self.selectedspikes_curves.append([ ]) for i in range(len(self.analogsignals)): curve = make.curve([ ], [ ], markerfacecolor= 'm',marker = 'o' , linestyle = '', markersize = 8 )#, alpha = .3) self.selectedspikes_curves[p].append( curve ) self.plots[p].add_item(curve) self.refresh()
def plot(self, curve): _plot = self.get_plot() _plot.add_item(make.curve(array(curve.get_plottable_data().index, dtype=float), curve.get_plottable_data().values, color=self.get_next_color(), title='['+str(curve.id)+']'+curve.name) ) _plot.replot() #_plot.set_axis_font("left", QFont("Courier"))
def onCalculate(self): self.calc() fret_line = make.curve(self.fluorescence_averaged_lifetimes, self.fret_efficiencies, color="r", linewidth=2) self.fret_line_plot.add_item(fret_line) self.fret_line_plot.do_autoscale() self.lineEdit.setText(self.transfer_efficency_string) self.lineEdit_2.setText(self.fdfa_string) self.lineEdit_3.setText("%s" % list(self.polynom_coefficients))
def SpectrumVisu(self,item,value,parent): #app=guidata.qapplication() from guiqwt.curve import CurvePlot plot=CurvePlot(title="spectrum",xlabel="x",ylabel="y") number1=self.chosensoil1 spectrum1=Set.SpectrumList[number1] x1=range(len(spectrum1)) number2=self.chosensoil2 spectrum2=Set.SpectrumList[number2] x2=range(len(spectrum2)) from guiqwt.builder import make curve1=make.curve(x1,spectrum1,title="curve1",color='b') plot.add_item(curve1) curve2=make.curve(x2,spectrum2,title="curve2",color='r') plot.add_item(curve2) #app.exec_() plot.show() print(self.chosensoil1)
def plot_init(self): self.manager = PlotManager(self) self.plots = [] self.plot = CurvePlot(xlabel="", ylabel="") # self.plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(10) self.manager.add_plot(self.plot) self.plots.append(self.plot) self.plot.plot_id = id(self.plot) self.curve = make.curve([0], [0], color="blue", title="gray value") self.plot.add_item(self.curve) self.plot.add_item(make.legend("TR")) self.ui_obj.line_info_display.addWidget(self.plot)
def __init__(self, parent, plot, col='b'): super(ObjectFT, self).__init__(Qt.Vertical, parent) self.plot = plot self.curve = make.curve([], [], color=col) self.plot.add_item(self.curve) self.hCursor = None self.vCursor = None self.xRange = None # holds limits of bounds self.xMinMax = None # holds limits of data min and max, necessary to initialize once before axis change is possible self.scaleFun = lambda x: x self.scaleFunInv = lambda x: x
def hist2d_func(X, Y, Z): win = ImageDialog(edit=True, toolbar=True, wintitle="2-D Histogram X0=(0,1), X1=(-1,-1)") hist2d = make.histogram2D(X, Y, 200, 200, Z=Z, computation=2) curve = make.curve(X[::50], Y[::50], linestyle="", marker="+", title=_("Markers")) plot = win.get_plot() plot.set_aspect_ratio(lock=False) plot.set_antialiasing(False) plot.add_item(hist2d) plot.add_item(curve) plot.set_item_visible(curve, False) win.show() win.exec_()
def Plot_Start_New(widget,PLOT_DEFINE,COLORS,x1,x2,y1,y2): newmanager = PlotManager(widget) newplots = [] newcurves = {} for name in PLOT_DEFINE: plot = CurvePlot() #设置图表颜色 plot.setStyleSheet('''QWidget{ border: 1px solid #32435E; border-radius: 3px; font-size:11pt; color:white; font-family:"Microsoft YaHei UI"; /* padding: 0 8px; */ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #080B10, stop: 1.0 #212C3F); selection-background-color: #0A246A; } ''' ) plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(20) newplots.append(plot) newmanager.add_plot(plot) plot.plot_id = id(plot) for curve_color, curve_name in map(None,COLORS,name): if u"状态" in curve_name or u"打角/100" in curve_name : newcurves[curve_name] = guiqwt_make.curve([0], [0],markerfacecolor = 'black', markeredgecolor=curve_color, title=curve_name,marker = 'Diamond',linestyle = 'NoPen',markersize = 6) else: newcurves[curve_name] = guiqwt_make.curve([0], [0], color=curve_color, title=curve_name) plot.add_item(newcurves[curve_name]) #设置X轴y轴 plot.set_axis_limits(newcurves[curve_name].yAxis(),y1,y2) plot.set_axis_limits(newcurves[curve_name].xAxis(),x1,x2) plot.add_item(guiqwt_make.legend("BL")) newmanager.register_standard_tools() newmanager.get_default_tool().activate() return (newmanager,newplots,newcurves)