How to use pyqtgraph - 10 common examples

To help you get started, we’ve selected a few pyqtgraph examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github habom2310 / Heart-rate-measurement-using-camera / new_update / test_signal_processing.py View on Github external
video_fps = cap.get(cv2.CAP_PROP_FPS) # for video capture
    print(video_fps)
    
    times = []
    data_buffer = []
    
    # data for plotting
    filtered_data = []
    
    fft_of_interest = []
    freqs_of_interest = []
    
    bpm = 0
    
    #plotting
    app = QtGui.QApplication([])  
    
    win = pg.GraphicsWindow(title="plotting")
    p1 = win.addPlot(title="FFT")
    p2 = win.addPlot(title ="Signal")
    win.resize(1200,600)
    
    def update():
        p1.clear()
        p1.plot(np.column_stack((freqs_of_interest,fft_of_interest)), pen = 'g')
        
        p2.clear()
        p2.plot(filtered_data[20:],pen='g')
        app.processEvents()
    
    timer = QtCore.QTimer()
    timer.timeout.connect(update)
github Closius / crypto_trader / trader / monitor_test_misc.py View on Github external
self.plot3.getAxis("bottom").tickFont = font
        self.plot3.getAxis("left").tickFont = font
        # self.plot3.addLegend()
        self.plot3.showGrid(x = True, y = True, alpha = 0.7)
        self.USD_graph.show()


        # ===============================================================
        #                      Scroll range
        # ===============================================================
        self.data = {
            "begin_datetime": None,
            "end_datetime": None
        }

        self.begin_vLine = pg.InfiniteLine(angle=90, movable=False, pen=pg.mkPen('g', width=4, style=QtCore.Qt.SolidLine))
        self.begin_vLine_USD = pg.InfiniteLine(angle=90, movable=False, pen=pg.mkPen('g', width=4, style=QtCore.Qt.SolidLine))
        self.begin_vLine_BTC = pg.InfiniteLine(angle=90, movable=False, pen=pg.mkPen('g', width=4, style=QtCore.Qt.SolidLine))

        self.top_midway_hLine = pg.InfiniteLine(angle=0, movable=False, pen=pg.mkPen('y', width=2, style=QtCore.Qt.DotLine))#  DashLine))
        self.bottom_midway_hLine = pg.InfiniteLine(angle=0, movable=False, pen=pg.mkPen('r', width=2, style=QtCore.Qt.DotLine))#  DashLine))


        self.end_vLine = pg.InfiniteLine(angle=90, movable=False, pen=pg.mkPen('m', width=4, style=QtCore.Qt.SolidLine))
        self.plot1.addItem(self.begin_vLine, ignoreBounds=True)
        self.plot2.addItem(self.begin_vLine_BTC, ignoreBounds=True)
        self.plot3.addItem(self.begin_vLine_USD, ignoreBounds=True)

        self.plot1.addItem(self.top_midway_hLine, ignoreBounds=True)
        self.plot1.addItem(self.bottom_midway_hLine, ignoreBounds=True)

        self.plot1.addItem(self.end_vLine, ignoreBounds=True)
github Closius / crypto_trader / trader / monitor_test_misc.py View on Github external
self.end_vLine = pg.InfiniteLine(angle=90, movable=False, pen=pg.mkPen('m', width=4, style=QtCore.Qt.SolidLine))
            self.plot1.addItem(self.begin_vLine, ignoreBounds=True)
            self.plot1.addItem(self.end_vLine, ignoreBounds=True)

            self.top_midway_hLine = pg.InfiniteLine(angle=0, movable=False, pen=pg.mkPen('y', width=2, style=QtCore.Qt.DotLine))#  DashLine))
            self.bottom_midway_hLine = pg.InfiniteLine(angle=0, movable=False, pen=pg.mkPen('r', width=2, style=QtCore.Qt.DotLine))#  DashLine))
            self.plot1.addItem(self.top_midway_hLine, ignoreBounds=True)
            self.plot1.addItem(self.bottom_midway_hLine, ignoreBounds=True)

        if "strategy" in parts:

            self.plot2.clear()
            self.plot3.clear()

            self.begin_vLine_BTC = pg.InfiniteLine(angle=90, movable=False, pen=pg.mkPen('g', width=4, style=QtCore.Qt.SolidLine))
            self.begin_vLine_USD = pg.InfiniteLine(angle=90, movable=False, pen=pg.mkPen('g', width=4, style=QtCore.Qt.SolidLine))
            self.plot2.addItem(self.begin_vLine_BTC, ignoreBounds=True)
            self.plot3.addItem(self.begin_vLine_USD, ignoreBounds=True)

            # self.win_pg_left.scene().removeItem(self.plot2.legend)
            # self.win_pg_right.scene().removeItem(self.plot3.legend)

            # self.plot2.addLegend()
            # self.plot3.addLegend()

            for item in self.plot1_sell_buy:
                self.plot1.removeItem(item)

            self.plot1_sell_buy = []
github fedebarabas / tormenta / tormenta / control / control.py View on Github external
self.recFormat = QtGui.QComboBox(self)
        self.recFormat.addItem('tiff')
        self.recFormat.addItem('hdf5')
        self.recFormat.setFixedWidth(50)

        # Number of frames and measurement timing
        self.currentFrame = QtGui.QLabel('0 /')
        self.currentFrame.setAlignment((QtCore.Qt.AlignRight |
                                        QtCore.Qt.AlignVCenter))
        self.currentFrame.setFixedWidth(45)
        self.numExpositionsEdit = QtGui.QLineEdit('100')
        self.numExpositionsEdit.setFixedWidth(45)
        self.tRemaining = QtGui.QLabel()
        self.tRemaining.setStyleSheet("font-size:14px")
        self.tRemaining.setAlignment((QtCore.Qt.AlignCenter |
                                      QtCore.Qt.AlignVCenter))
        self.numExpositionsEdit.textChanged.connect(self.nChanged)
        self.updateRemaining()

        self.progressBar = QtGui.QProgressBar()
        self.progressBar.setTextVisible(False)
        self.progressBar.setSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Expanding)
        self.fileSizeLabel = QtGui.QLabel()
        self.nChanged()

        # Recording buttons layout
        buttonWidget = QtGui.QWidget()
        buttonGrid = QtGui.QGridLayout(buttonWidget)
        buttonGrid.addWidget(self.snapButton, 0, 0)
        buttonWidget.setSizePolicy(QtGui.QSizePolicy.Preferred,
                                   QtGui.QSizePolicy.Expanding)
github GeoPyTool / GeoPyTool / Experimental / PyQtGraphic.py View on Github external
numpyMatrix = df.as_matrix()

newdf = pd.concat([df.SiO2 ,df.Ratio, df.CaO], axis=1)

X= newdf.as_matrix()



## Define a top-level widget to hold everything
w = QtGui.QWidget()

## Create some widgets to be placed inside
btn = QtGui.QPushButton('press me')
text = QtGui.QLineEdit('enter text')
listw = QtGui.QListWidget()
view = pg.PlotWidget()
view.addLegend()

view.plot(X[:, 0], X[:,2], pen=None, symbol='o', symbolPen=None, symbolSize=10, symbolBrush=(100, 255, 255, 88), name=y[0])

## Create a grid layout to manage the widgets size and position
layout = QtGui.QGridLayout()
w.setLayout(layout)

## Add widgets to the layout in their proper positions
layout.addWidget(btn, 0, 0)   # button goes in upper-left
layout.addWidget(text, 1, 0)   # text edit goes in middle-left
layout.addWidget(listw, 2, 0)  # list widget goes in bottom-left
layout.addWidget(view, 0, 1, 3, 1)  # plot goes on right side, spanning 3 rows

## Display the widget as a new window
w.show()
github daniel-muthukrishna / astrodash / astrodash / design.py View on Github external
font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.horizontalLayout_2.addWidget(self.label_4)
        self.lineEditRedshift = QtWidgets.QLineEdit(self.groupBox_4)
        self.lineEditRedshift.setObjectName("lineEditRedshift")
        self.horizontalLayout_2.addWidget(self.lineEditRedshift)
        self.horizontalSliderRedshift = QtWidgets.QSlider(self.groupBox_4)
        self.horizontalSliderRedshift.setMaximum(10000)
        self.horizontalSliderRedshift.setOrientation(QtCore.Qt.Horizontal)
        self.horizontalSliderRedshift.setObjectName("horizontalSliderRedshift")
        self.horizontalLayout_2.addWidget(self.horizontalSliderRedshift)
        self.horizontalLayout_2.setStretch(6, 1)
        self.horizontalLayout_2.setStretch(7, 6)
        self.verticalLayout_9.addLayout(self.horizontalLayout_2)
        self.graphicsView_2 = PlotWidget(self.groupBox_4)
        self.graphicsView_2.setObjectName("graphicsView_2")
        self.verticalLayout_9.addWidget(self.graphicsView_2)
        self.graphicsView = PlotWidget(self.groupBox_4)
        self.graphicsView.setObjectName("graphicsView")
        self.verticalLayout_9.addWidget(self.graphicsView)
        self.verticalLayout_9.setStretch(2, 1)
        self.verticalLayout_9.setStretch(3, 5)
        self.verticalLayout_2.addWidget(self.groupBox_4)
        self.verticalLayout_2.setStretch(0, 3)
        self.verticalLayout_2.setStretch(1, 11)
        self.horizontalLayout_3.addLayout(self.verticalLayout_2)
        self.horizontalLayout_3.setStretch(0, 9)
        self.horizontalLayout_3.setStretch(1, 32)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1205, 22))
github gabrielibagon / ECG_Respiratory_Monitor / heart-monitor.py View on Github external
def main():
	db = Data_Buffer()
	app = QtGui.QApplication(sys.argv)
	gui = GUI(data_buffer=db)
	sys.exit(app.exec_())
github pyqtgraph / pyqtgraph / pyqtgraph / multiprocess / processes.py View on Github external
def processRequests(self):
        try:
            RemoteEventHandler.processRequests(self)
        except ClosedError:
            from ..Qt import QtGui, QtCore
            QtGui.QApplication.instance().quit()
            self.timer.stop()
            #raise SystemExit
github flika-org / flika / plugins / detect_puffs / puffAnalyzer.py View on Github external
super(PuffAnalyzer,self).__init__(parent) ## Create window with ImageView widget
        self.puffs=puffs
        self.setWindowTitle('Puff Analyzer')
        self.setGeometry(QtCore.QRect(360, 368, 1552, 351))
        self.l = QtGui.QVBoxLayout()
        self.l_mid=QtGui.QGridLayout()
        self.threeD_Holder=QtGui.QHBoxLayout()
        self.l_bottom=QtGui.QGridLayout()
        self.p1=pg.PlotWidget()
        self.p4=pg.PlotWidget()
        self.p1.setMaximumWidth(600)
        #self.p1.setAutoVisible(y=True)
        self.p2=Puff3d(self.puffs)
        self.p3=Puff3d_fit(self.puffs)
        self.show()
        self.vLine = pg.InfiniteLine(angle=90, movable=True)
        self.vLine.setPos(self.puffs[0].position[0])
        self.startLine = pg.InfiniteLine(pen=QPen(Qt.green),angle=90, movable=True)
        self.startLine.setPos(self.puffs[0].position[0])
        self.endLine = pg.InfiniteLine(pen=QPen(Qt.cyan),angle=90, movable=True)
        self.endLine.setPos(self.puffs[0].position[0])        
        
        self.proxy = pg.SignalProxy(self.vLine.sigDragged, rateLimit=60, slot=self.lineDragged)
        self.proxy2 = pg.SignalProxy(self.startLine.sigDragged, rateLimit=60, slot=self.startlineDragged)
        self.proxy3 = pg.SignalProxy(self.endLine.sigDragged, rateLimit=60, slot=self.endlineDragged)
        
        self.prevButton=QtGui.QPushButton('Previous')
        self.currentPuff_spinbox=QtGui.QSpinBox()
        self.currentPuff_spinbox.setMaximum(len(self.puffs.puffs)-1)
        self.nextButton=QtGui.QPushButton('Next')
        self.nextButton.pressed.connect(self.increment)
        self.currentPuff_spinbox.valueChanged.connect(self.setCurrPuff)
github Ulm-IQO / qudi / gui / pulsed / pulsed_maingui_simple.py View on Github external
def fit_clicked(self):
		# clear old fit results in the text box        self._mw.fit_result_TextBrowser.clear()
        # remove old fit from the graph
        self._mw.signal_plot_ViewWidget.removeItem(self.fit_image)
        # get selected fit function from the ComboBox
        current_fit_function = self._mw.fit_function_ComboBox.currentText()

        fit_x, fit_y, fit_result = self._pulsed_measurement_logic.do_fit(current_fit_function)

        # plot the fit only if there is data available

        if fit_x != [] and fit_x != []:

            self.fit_image = pg.PlotDataItem(fit_x, fit_y,pen='r')
            self._mw.signal_plot_ViewWidget.addItem(self.fit_image,pen='r')

        self._mw.fit_result_TextBrowser.setPlainText(fit_result)

        return
    def refresh_lasertrace_plot(self):