Python pyqtgraph 模块,LinearRegionItem() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用pyqtgraph.LinearRegionItem()

项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, parent=None,**kwargs):
        super(AppWindow, self).__init__(parent)
        self.setupUi(self)
        self.I=kwargs.get('I',None)
        from PSL.analyticsClass import analyticsClass
        self.CC = analyticsClass()

        self.setWindowTitle(self.I.H.version_string+' : '+params.get('name','').replace('\n',' ') )

        self.plot1=self.add2DPlot(self.plot_area)
        labelStyle = {'color': 'rgb(255,255,255)', 'font-size': '11pt'}
        self.plot1.setLabel('left','Voltage -->', units='V',**labelStyle)
        self.plot1.setLabel('bottom','Time -->', units='S',**labelStyle)

        self.plot1.setYRange(-8.5,8.5)
        self.I.set_gain('CH1',1)
        self.I.configure_trigger(0,'CH1',0)
        self.tg=1
        self.tgLabel.setText(str(5000*self.tg*1e-3)+'mS')
        self.x=[]

        self.looptimer=QtCore.QTimer()
        self.curveCH1 = self.addCurve(self.plot1,'CH1')
        self.CH1Fit = self.addCurve(self.plot1,'CH1 Fit')
        self.region = pg.LinearRegionItem([self.tg*50,self.tg*800])
        self.region.setZValue(-10)
        self.plot1.addItem(self.region)     
        self.lognum=0
        self.state=0
        self.I.set_state(SQR1=0)
        self.msg.setText("Fitting fn :\noff+amp*exp(-damp*x)*sin(x*freq+ph)")
        self.Params=[]
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, parent=None,**kwargs):
        super(AppWindow, self).__init__(parent)
        self.setupUi(self)
        self.I=kwargs.get('I',None)
        self.IMU = MPU6050.connect(self.I.I2C)
        from PSL.analyticsClass import analyticsClass
        self.CC = analyticsClass()

        self.setWindowTitle(self.I.H.version_string+' : '+params.get('name','').replace('\n',' ') )

        self.plot1=self.add2DPlot(self.plot_area)
        labelStyle = {'color': 'rgb(255,255,255)', 'font-size': '11pt'}
        self.plot1.setLabel('left','Acceleration -->', units='V',**labelStyle)
        self.plot1.setLabel('bottom','Time -->', units='S',**labelStyle)

        self.tg=2000
        self.tgLabel.setText(str(2000*self.tg*1e-3)+'mS')
        self.curveGx = self.addCurve(self.plot1,'Gx')
        self.curveGy = self.addCurve(self.plot1,'Gy')
        self.curveGz = self.addCurve(self.plot1,'Gz')
        self.plot2 = self.addAxis(self.plot1)
        self.curveAx = self.addCurve(self.plot2,'Ax')
        self.curveAy = self.addCurve(self.plot2,'Ay')
        self.curveAz = self.addCurve(self.plot2,'Az')
        self.curves = [self.curveAx,self.curveAy,self.curveAz,self.curveGx,self.curveGy,self.curveGz]
        self.curveNames=['Ax','Ay','Az','Gx','Gy','Gz']
        self.legend=self.plot1.addLegend(offset=(-10,30))

        for a in range(6):
            self.legend.addItem(self.curves[a],self.curveNames[a])

        self.datasets = [[],[],[],[],[],[]]
        self.looptimer=QtCore.QTimer()
        self.region = pg.LinearRegionItem([self.tg*50*1e-6,self.tg*800*1e-6])
        self.region.setZValue(-10)
        self.plot1.addItem(self.region)     
        self.lognum=0
        self.msg.setText("Fitting fn :\noff+amp*exp(-damp*x)*sin(x*freq+ph)")
        self.Params=[]
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, parent=None,**kwargs):
        super(AppWindow, self).__init__(parent)
        self.setupUi(self)
        self.I=kwargs.get('I',None)
        self.CC = analyticsClass()

        self.setWindowTitle(self.I.H.version_string+' : '+params.get('name','').replace('\n',' ') )

        self.plot=self.add2DPlot(self.plot_area)
        labelStyle = {'color': 'rgb(255,255,255)', 'font-size': '11pt'}
        self.plot.setLabel('left','Voltage -->', units='V',**labelStyle)
        self.plot.setLabel('bottom','Time -->', units='S',**labelStyle)

        self.plot.setYRange(-8.5,8.5)
        self.tg=100
        self.tgLabel.setText(str(5000*self.tg*1e-3)+'S')
        self.x=[]
        self.CParams=[0,0,0,0,0]

        self.FitTable.setHorizontalHeaderLabels(['Amp','Freq','Phase','Offset','Damping'])
        for a in range(5):
            item = QtGui.QTableWidgetItem()
            self.FitTable.setItem(0,a,item)
            item.setText('Nil')


        self.curveCH1 = self.addCurve(self.plot,'CH3')
        self.CH1Fit = self.addCurve(self.plot,'CH3 Fit')
        self.region = pg.LinearRegionItem([self.tg*50*1e-6,self.tg*800*1e-6])
        self.region.setZValue(-10)
        self.plot.addItem(self.region)      
        self.msg.setText("Function:offset+A*exp(-damp*x)*sin(x*freq+ph)")
        self.running=True
        self.Params=[]
        self.looptimer=QtCore.QTimer()
        self.looptimer.timeout.connect(self.updateProgress)
        self.I.set_w1(1)
项目:specviz    作者:spacetelescope    | 项目源码 | 文件源码
def __init__(self, removable=True, *args, **kwargs):
        super(LinearRegionItem, self).__init__(*args, **kwargs)

        self.menu = None
        self.removable = removable
        self.deletable = removable
项目:orange-infrared    作者:markotoplak    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        pg.LinearRegionItem.__init__(self, *args, **kwargs)
        for l in self.lines:
            l.setCursor(Qt.SizeHorCursor)
        self.setZValue(10)
        color = QColor(Qt.red)
        color.setAlphaF(0.05)
        self.setBrush(pg.mkBrush(color))
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def __init__(self, parent=None,**kwargs):
        super(AppWindow, self).__init__(parent)
        self.setupUi(self)
        self.I=kwargs.get('I',None)
        self.I.__ignoreCalibration__()

        self.table = myTable()
        self.tableLayout.addWidget(self.table)

        #Reset existing calibration in software!
        self.reset()


        self.hexid = hex(self.I.device_id())
        self.setWindowTitle(self.I.generic_name + ' : '+self.I.H.version_string.decode("utf-8")+' : '+self.hexid)

        #Check DIO and freq counter
        for a in ['SQR1','SQR2','SQR3','SQR4']:
            x = {'SQR1':0,'SQR2':0,'SQR3':0,'SQR4':0}
            x[a]=1
            self.I.set_state(**x)
            time.sleep(0.1)
        self.I.sqrPWM(10000,0.5,0,0.5,0,0.5,0,0.5)
        for a in ['ID1','ID2','ID3','ID4','CNTR']:
            if abs(self.I.get_freq(a,0.2)-10000)>2:
                self.setWindowTitle('D/IO error!!!!!!!!!!!!!!!!!!!!!!!' + ' : '+self.hexid)
        self.I.set_state(SQR1=0,SQR2=0,SQR3=0,SQR4=0)
        self.plot=self.add2DPlot(self.plot_area)


        self.plot=self.add2DPlot(self.plot_area)
        labelStyle = {'color': 'rgb(255,255,255)', 'font-size': '11pt'}
        self.plot.setLabel('left','Error -->', units='V',**labelStyle)
        self.plot.setLabel('bottom','Actual Voltage -->', units='V',**labelStyle)
        self.plot.setYRange(-.06,.06)

        self.region = pg.LinearRegionItem([-1.,1.])
        self.region.setZValue(-10)
        self.plot.addItem(self.region)      

        self.opendir = QtGui.QPushButton('open')
        self.opendir.clicked.connect(self.loadDir)
        self.WidgetLayout.addWidget(self.opendir)

        self.uploadButton = QtGui.QPushButton('Upload')
        self.uploadButton.clicked.connect(self.uploadCalibration)
        self.WidgetLayout.addWidget(self.uploadButton)

        self.results={}
        self.DAC_POLYS=[]
        self.INL_SLOPE=0
        self.INL_INTERCEPT=0
        self.adc_shifts=[]
        self.DAC_FILES=[]
        self.DAC_TABLES=[]
        self.dirname = ''
        self.ADDITIONAL_FILE = 'CAP_PCS.csv'
项目:FoundryDataBrowser    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):

        self.settings.New('spec_index', dtype=int, initial=0)
        self.settings.spec_index.add_listener(self.on_spec_index_change)

        self.ui = QtWidgets.QGroupBox()
        self.ui.setLayout(QtWidgets.QVBoxLayout())

        self.ui.spec_index_doubleSpinBox = QtWidgets.QDoubleSpinBox()
        self.settings.spec_index.connect_bidir_to_widget(self.ui.spec_index_doubleSpinBox)
        self.ui.layout().addWidget(self.ui.spec_index_doubleSpinBox)

        self.graph_layout = pg.GraphicsLayoutWidget()
        self.ui.layout().addWidget(self.graph_layout)

        self.power_plot = self.graph_layout.addPlot()
        self.power_plot.setLogMode(x=True, y=True)

        self.power_plotcurve = self.power_plot.plot([1],[1], name='Data')

        self.power_fit_plotcurve = self.power_plot.plot([1],[1],pen='r', name='Fit')

        self.power_plot_arrow = pg.ArrowItem()
        self.power_plot_arrow.setPos(0,0)
        self.power_plot.addItem(self.power_plot_arrow)

        self.power_plot_lr = pg.LinearRegionItem([1,2])
        self.power_plot_lr.setZValue(-10)
        self.power_plot.addItem(self.power_plot_lr)
        self.power_plot_lr.sigRegionChanged.connect(self.redo_fit)

        #self.power_plot_legend = pg.LegendItem()
        #self.power_plot.addItem(self.power_plot_legend)
        #self.power_plot_legend.addItem(self.power_plotcurve)
        #self.power_plot_legend.addItem(self.power_fit_plotcurve)
        self.fit_text = pg.TextItem("fit")
        self.fit_text.setParentItem(self.power_plot_lr, )

        self.graph_layout.nextRow()

        self.spec_plot = self.graph_layout.addPlot()
        self.spec_plotcurve = self.spec_plot.plot([0])
项目:ConvNetQuake    作者:tperol    | 项目源码 | 文件源码
def plot_trace(self):
    event_time = self.filtered_catalog.utc_timestamp.values[self.event_idx]
    self.statusBar.showMessage('Event {} of {}: {}'.format(
      self.event_idx+1, self.num_events, utc.UTCDateTime(event_time)))

    window_sz = 20 # in sec
    utc_time = utc.UTCDateTime(event_time)
    start = utc_time
    end = utc_time+window_sz
    local_stream = self.stream.slice(start, end)
    local_stream.filter('highpass', freq=2.0)

    sample_rate = local_stream[0].stats.sampling_rate
    npts = local_stream[0].stats.npts

    event_sample = (utc_time-start)*sample_rate

    n_traces = len(local_stream)
    n_samples = len(local_stream[0].data)
    data = np.zeros((n_traces, n_samples), dtype=np.float32)
    for i in range(n_traces):
        data[i, :] = local_stream[i].data[...]
        mean = np.mean(data[i, :])
        data[i, :] -= mean

    self.trace_x.clear()
    self.trace_y.clear()
    self.trace_z.clear()

    self.trace_x.plot(data[0, :], pen=(255,120,120,200))
    self.trace_y.plot(data[1, :], pen=(120,255,120,200))
    self.trace_z.plot(data[2, :], pen=(120,120,255,200))

    self.lrx = pg.LinearRegionItem([event_sample,event_sample+sample_rate*1])
    self.lrx.setZValue(-10)
    self.trace_x.addItem(self.lrx)

    # lry = pg.LinearRegionItem([400,700])
    # lry.setZValue(-10)
    # self.trace_y.addItem(lry)
    #
    # lrz = pg.LinearRegionItem([400,700])
    # lrz.setZValue(-10)
    # self.trace_z.addItem(lrz)
    #
    # regions = [lrx, lry, lrz]
    #
    # def updateRange(lr, regions):
    #   for l in regions:
    #     if l != lr:
    #       l.setRegion(lr.getRegion())
    #
    # # for l in regions:
    # lrx.sigRegionChanged.connect(lambda : updateRange(lrx, regions))
    # lry.sigRegionChanged.connect(lambda : updateRange(lry, regions))
    # lrz.sigRegionChanged.connect(lambda : updateRange(lrz, regions))