def update_all_curves(self, data, labels, ranges, mscore, intensity, assay_rt, show_legend): assert len(data) == len( labels ), "Length of labels %s does not correspond to length of data %s" % ( len(labels), len(data)) self.create_curves(labels, ranges, show_legend) if mscore is not None and len(ranges) < 2: self.mscore_label = make.label("m_score=%0.4g" % mscore, "TL", (0, 0), "TL") self.get_plot().add_item(self.mscore_label) self.l2 = make.label("Int=%0.4g" % intensity, "TL", (0, 25), "TL") self.get_plot().add_item(self.l2) self.width = make.label( "PeakWidth=%0.3fs" % (ranges[0][1] - ranges[0][0]), "TL", (0, 50), "TL") self.get_plot().add_item(self.width) self.assay_rt = make.label("Assay RT=%0.3fs" % (assay_rt), "TL", (0, 75), "TL") self.get_plot().add_item(self.assay_rt) for d, curve in zip(data, self.curves): curve.set_data(d[0], d[1]) self.get_plot().do_autoscale()
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 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 test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- from numpy import linspace, sin x = linspace(-10, 10, 200) dy = x / 100. 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., .8), label_cb=lambda x, y: "A = %.2f" % x, markerstyle="|", movable=False))
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) 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 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=None): super(CrossSectionPlot, self).__init__(parent=parent, title="", section="cross_section") self.perimage_mode = True self.autoscale_mode = True self.autorefresh_mode = True self.apply_lut = False self.single_source = False self.last_obj = None self.known_items = {} self._shapes = {} self.curveparam = CurveParam(_("Curve"), icon="curve.png") self.set_curve_style("cross_section", "curve") if self._height is not None: self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) elif self._width is not None: self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) self.label = make.label(self.LABEL_TEXT, "C", (0, 0), "C") self.label.set_readonly(True) self.add_item(self.label) self.setAxisMaxMajor(self.Z_AXIS, self.Z_MAX_MAJOR) self.setAxisMaxMinor(self.Z_AXIS, 0)
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 update_all_curves(self, data, labels, ranges, mscore, intensity, show_legend=True): assert len(data) == len(labels), "Length of labels %s does not correspond to length of data %s" % (len(labels), len(data)) self.create_curves(labels, ranges, show_legend) if mscore is not None and len(ranges) < 2: self.mscore_label = make.label("m_score=%0.4g" % mscore, "TL", (0,0), "TL") self.get_plot().add_item( self.mscore_label ) self.l2 = make.label("Int=%0.4g" % intensity, "TL", (0,25), "TL") self.get_plot().add_item( self.l2 ) self.width = make.label("PeakWidth=%0.3fs" % (ranges[0][1]-ranges[0][0]), "TL", (0,50), "TL") self.get_plot().add_item( self.width ) for d, curve in zip(data, self.curves): curve.set_data( d[0], d[1] ) self.get_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.0, "rc1"), make.segment(-3, -0.8, -0.5, -1.0, "se1"), make.ellipse(-10, 0.0, 0, 0, "el1"), make.annotated_rectangle(0.5, 0.8, 3, 1.0, "rc1", "tutu"), make.annotated_segment(-1, -1, 1, 1.0, "rc1", "tutu"), Axes((0, 0), (1, 0), (0, 1)), PolygonShape( np.array( [ [150.0, 330.0], [270.0, 520.0], [470.0, 480.0], [520.0, 360.0], [460.0, 200.0], [250.0, 240.0], ] ) ), ] return items
def test(): """Test""" # -- Create QApplication import guidata _app = guidata.qapplication() # -- from numpy import linspace, sin 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.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 __init__( self, fit: fitting.fit.FitGroup, d_scalex: str = 'lin', d_scaley: str = 'lin', r_scalex: str = 'lin', r_scaley: str = 'lin', **kwargs ): super(GlobalAnisotropy, self).__init__( fit=fit, **kwargs ) self.verbose = kwargs.get('verbose', chisurf.verbose) self.layout = QtWidgets.QVBoxLayout(self) self.fit = fit bottom = QtWidgets.QFrame(self) bottom.setFrameShape(QtWidgets.QFrame.StyledPanel) botl = QtWidgets.QVBoxLayout(bottom) top = QtWidgets.QFrame(self) top.setMaximumHeight(140) top.setFrameShape(QtWidgets.QFrame.StyledPanel) topl = QtWidgets.QVBoxLayout(top) splitter1 = QtWidgets.QSplitter(QtCore.Qt.Vertical) splitter1.addWidget(top) splitter1.addWidget(bottom) self.layout.addWidget(splitter1) # Data-Fit dialog fd = CurveDialog(edit=False, toolbar=True) #self.get_itemlist_panel().show() plot = fd.get_plot() self.data_curve_vv = make.curve([], [], color="b", linewidth=1) self.irf_curve_vv = make.curve([], [], color="r", linewidth=1) self.model_curve_vv = make.curve([], [], color="g", linewidth=4) self.data_curve_vh = make.curve([], [], color="c", linewidth=1) self.irf_curve_vh = make.curve([], [], color="m", linewidth=1) self.model_curve_vh = make.curve([], [], color="k", linewidth=4) plot.add_item(self.data_curve_vv) plot.add_item(self.irf_curve_vv) plot.add_item(self.model_curve_vv) plot.add_item(self.data_curve_vh) plot.add_item(self.irf_curve_vh) plot.add_item(self.model_curve_vh) self.dataPlot = plot botl.addWidget(fd) splitter1 = QtWidgets.QSplitter(QtCore.Qt.Horizontal) topl.addWidget(splitter1) # Residual dialog win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.residual_curve_vv = make.curve([], [], color="r", linewidth=2) self.residual_curve_vh = make.curve([], [], color="b", linewidth=2) plot.add_item(self.residual_curve_vv) plot.add_item(self.residual_curve_vh) self.chi2_label = make.label("", "R", (-10, 27), "R") plot.add_item(self.chi2_label) title = make.label("w.res.", "R", (0, -40), "R") plot.add_item(title) self.residualPlot = plot splitter1.addWidget(plot) win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.autocorr_curve_vv = make.curve([], [], color="r", linewidth=2) self.autocorr_curve_vh = make.curve([], [], color="b", linewidth=2) plot.add_item(self.autocorr_curve_vv) plot.add_item(self.autocorr_curve_vh) title = make.label("auto.cor.", "R", (0, -40), "R") plot.add_item(title) self.autoCorrPlot = plot splitter1.addWidget(plot) self.pltControl = LinePlotWidget( self, d_scalex, d_scaley, r_scalex, r_scaley )
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() adc=cx.acqiris_adc adc.select_device(0) adc.config_clock('INT') adc.config_horizontal(2048,1e-9,0) adc.config_trigger_class('EDGE', 'EXT1') adc.config_trigger_source('EXT1', 'DC', 'POS', 0.2000) adc.config_vertical(1, 0.05,0,'DC_50','NOLIM') adc.config_vertical(2, 0.05,0,'DC_50','NOLIM') testscan=adc.acquire(1000,[1,2], 5000) len(testscan) II=testscan.asarray[0] QQ=testscan.asarray[1] # MODE=np.sqrt(np.square(II)+np.square(QQ)) xx=range(2048) # 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, II, color="b"), make.curve(xx, QQ, color="g"), # make.curve(xx, MODE, color="r"), # make.curve(x, sin(2*y), color="r"), # make.merror(x, y/2, dy), make.label("ADC SCAN<b>test</b>", (xx[0], II[0]), (-10, -10), "BR"), make.label("ADC SCAN<b>test 2X</b>", (xx[0], QQ[0]), (-10, -10), "BR") # make.label("ADC SCAN<b>test 2X</b>", # (xx[0], MODE[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, fit, d_scalex='lin', d_scaley='lin', r_scalex='lin', r_scaley='lin'): Plot.__init__(self) self.layout = QtGui.QVBoxLayout(self) self.fit = fit bottom = QtGui.QFrame(self) bottom.setFrameShape(QtGui.QFrame.StyledPanel) botl = QtGui.QVBoxLayout(bottom) top = QtGui.QFrame(self) top.setMaximumHeight(140) top.setFrameShape(QtGui.QFrame.StyledPanel) topl = QtGui.QVBoxLayout(top) splitter1 = QtGui.QSplitter(QtCore.Qt.Vertical) splitter1.addWidget(top) splitter1.addWidget(bottom) self.layout.addWidget(splitter1) # Data-Fit dialog fd = CurveDialog(edit=False, toolbar=True) #self.get_itemlist_panel().show() plot = fd.get_plot() self.data_curve = make.curve([1], [1], color="b", linewidth=1) self.irf_curve = make.curve([1], [1], color="r", linewidth=1) self.model_curve = make.curve([1], [1], color="g", linewidth=4) plot.add_item(self.data_curve) plot.add_item(self.irf_curve) plot.add_item(self.model_curve) self.dataPlot = plot botl.addWidget(fd) splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal) topl.addWidget(splitter1) # Residual dialog win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.residual_curve = make.curve([1], [1], color="r", linewidth=2) plot.add_item(self.residual_curve) self.chi2_label = make.label("", "R", (-10, 27), "R") plot.add_item(self.chi2_label) title = make.label("w.res.", "R", (0, -40), "R") plot.add_item(title) self.residualPlot = plot splitter1.addWidget(plot) win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.autocorr_curve = make.curve([1], [1], color="r", linewidth=2) plot.add_item(self.autocorr_curve) title = make.label("auto.cor.", "R", (0, -40), "R") plot.add_item(title) self.autoCorrPlot = plot splitter1.addWidget(plot) self.pltControl = linePlotWidget(self, d_scalex, d_scaley, r_scalex, r_scaley)
def __init__( self, fit: fitting.fit.FitGroup, f_scalex: str = 'log', f_scaley: str = 'lin', e_scalex: str = 'log', e_scaley: str = 'lin', *args, **kwargs ): self.fit = fit ## Distance distribution plot fd = CurveDialog(edit=False, toolbar=False) plot = fd.get_plot() self.p_rda_plot = plot self.verticalLayout_12.addWidget(fd) self.p_rda_curve = make.curve([1], [1], color="r", linewidth=2) plot.add_item(self.p_rda_curve) ## Fluorescence intensity plot win = CurveDialog(edit=False, toolbar=False) plot = win.get_plot() plot.do_autoscale(True) title = make.label("FDA,FD0", "R", (0, 10), "R") plot.add_item(title) self.fd0_curve = make.curve([1], [1], color="g", linewidth=2) self.fda_curve = make.curve([1], [1], color="r", linewidth=2) plot.add_item(self.fd0_curve) plot.add_item(self.fda_curve) self.fd_plot = plot self.fd_plot.set_scales(f_scalex, f_scaley) self.verticalLayout.addWidget(plot) ## Calculated E(t) plot win = CurveDialog(edit=False, toolbar=False) plot = win.get_plot() plot.do_autoscale(True) self.et_curve = make.curve([1], [1], color="b", linewidth=2) plot.add_item(self.et_curve) title = make.label("E(t)", "R", (0, 10), "R") plot.add_item(title) self.et_plot = plot self.et_plot.set_scales(e_scalex, e_scaley) self.verticalLayout_2.addWidget(plot) ## weighted-residuals of inversion win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.wres_curve = make.curve([1], [1], color="m", linewidth=2) plot.add_item(self.wres_curve) title = make.label("w.res", "R", (0, 10), "R") plot.add_item(title) self.wres_plot = plot self.wres_plot.set_scales('lin', 'lin') self.verticalLayout_3.addWidget(plot) ## L-Curve plot win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.l_curve_1 = make.curve([1], [1], color="k", linewidth=2) plot.add_item(self.l_curve_1) title = make.label("Reg.", "R", (0, 10), "R") plot.set_titles(ylabel='reg. par', xlabel='Chi2r') plot.add_item(title) self.l_curve_plot_1 = plot self.l_curve_plot_1.set_scales('lin', 'lin') self.verticalLayout_4.addWidget(self.l_curve_plot_1) win = CurveDialog(edit=False, toolbar=True) plot = win.get_plot() plot.do_autoscale(True) self.l_curve_2 = make.curve([1], [1], color="k", linewidth=2) plot.add_item(self.l_curve_2) title = make.label("L-Curve", "R", (0, 10), "R") plot.set_titles(ylabel='|x| (sol. norm)', xlabel='Chi2r') plot.add_item(title) self.l_curve_plot_2 = plot self.l_curve_plot_2.set_scales('log', 'log') self.verticalLayout_7.addWidget(self.l_curve_plot_2)