Python pyqtgraph.setConfigOption() Examples

The following are 13 code examples of pyqtgraph.setConfigOption(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyqtgraph , or try the search function .
Example #1
Source File: uiChanlunWidget.py    From chanlun with MIT License 7 votes vote down vote up
def generatePicture(self):
            ## pre-computing a QPicture object allows paint() to run much more quickly,
            ## rather than re-drawing the shapes every time.
            self.picture = QtGui.QPicture()
            p = QtGui.QPainter(self.picture)
            p.setPen(pg.mkPen(color='w', width=0.4))  # 0.4 means w*2
            a = pg.AxisItem('bottom', pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True)
            a.setFixedWidth(1)
            a.setWidth(1)
            a.setLabel(show=True)
            a.setGrid(grid=True)
            labelStyle = {'color': '#FFF', 'font-size': '14pt'}
            a.setLabel('label text', units='V', **labelStyle)
            # w = (self.data[1][0] - self.data[0][0]) / 3.
            w = 0.2
            for (t, open, close, min, max) in self.data:
                p.drawLine(QtCore.QPointF(t, min), QtCore.QPointF(t, max))
                if open > close:
                    p.setBrush(pg.mkBrush('g'))
                else:
                    p.setBrush(pg.mkBrush('r'))
                p.drawRect(QtCore.QRectF(t-w, open, w*2, close-open))
                pg.setConfigOption('leftButtonPan', False)
            p.end() 
Example #2
Source File: test_svg.py    From tf-pose with Apache License 2.0 6 votes vote down vote up
def test_plotscene():
    tempfilename = tempfile.NamedTemporaryFile(suffix='.svg').name
    print("using %s as a temporary file" % tempfilename)
    pg.setConfigOption('foreground', (0,0,0))
    w = pg.GraphicsWindow()
    w.show()        
    p1 = w.addPlot()
    p2 = w.addPlot()
    p1.plot([1,3,2,3,1,6,9,8,4,2,3,5,3], pen={'color':'k'})
    p1.setXRange(0,5)
    p2.plot([1,5,2,3,4,6,1,2,4,2,3,5,3], pen={'color':'k', 'cosmetic':False, 'width': 0.3})
    app.processEvents()
    app.processEvents()
    
    ex = pg.exporters.SVGExporter(w.scene())
    ex.export(fileName=tempfilename)
    # clean up after the test is done
    os.unlink(tempfilename) 
Example #3
Source File: uiChanlunWidget.py    From chanlun with MIT License 6 votes vote down vote up
def generatePicture(self):
            ## pre-computing a QPicture object allows paint() to run much more quickly,
            ## rather than re-drawing the shapes every time.
            self.picture = QtGui.QPicture()
            p = QtGui.QPainter(self.picture)
            p.setPen(pg.mkPen(color='w', width=0.4))  # 0.4 means w*2
            # w = (self.data[1][0] - self.data[0][0]) / 3.
            w = 0.2
            for (n, t, open, close, min, max) in self.data:
                p.drawLine(QtCore.QPointF(n, min), QtCore.QPointF(n, max))
                if open > close:
                    p.setBrush(pg.mkBrush('g'))
                else:
                    p.setBrush(pg.mkBrush('r'))
                p.drawRect(QtCore.QRectF(n-w, open, w*2, close-open))
                pg.setConfigOption('leftButtonPan', False)
            p.end() 
Example #4
Source File: go.py    From diyECG-1opAmp with MIT License 6 votes vote down vote up
def __init__(self, parent=None):
        pyqtgraph.setConfigOption('background', 'w') #before loading widget
        super(ExampleApp, self).__init__(parent)
        self.setupUi(self)
        self.grECG.plotItem.showGrid(True, True, 0.7)
        self.btnSave.clicked.connect(self.saveFig)
        self.btnSite.clicked.connect(self.website)
        stamp="DIY ECG by Scott Harden"
        self.stamp = pyqtgraph.TextItem(stamp,anchor=(-.01,1),color=(150,150,150),
                                        fill=pyqtgraph.mkBrush('w'))
        self.ear = swhear.Ear(chunk=int(100)) # determines refresh rate
        # optionally you can manually set the audio input device to use like this:
        # self.ear = swhear.Ear(chunk=int(100), device=5) # use audio input device 5
        if len(self.ear.valid_input_devices()):
            self.ear.stream_start()
            self.lblDevice.setText(self.ear.msg)
            self.update() 
Example #5
Source File: test_svg.py    From soapy with GNU General Public License v3.0 6 votes vote down vote up
def test_plotscene():
    tempfilename = tempfile.NamedTemporaryFile(suffix='.svg').name
    print("using %s as a temporary file" % tempfilename)
    pg.setConfigOption('foreground', (0,0,0))
    w = pg.GraphicsWindow()
    w.show()        
    p1 = w.addPlot()
    p2 = w.addPlot()
    p1.plot([1,3,2,3,1,6,9,8,4,2,3,5,3], pen={'color':'k'})
    p1.setXRange(0,5)
    p2.plot([1,5,2,3,4,6,1,2,4,2,3,5,3], pen={'color':'k', 'cosmetic':False, 'width': 0.3})
    app.processEvents()
    app.processEvents()
    
    ex = pg.exporters.SVGExporter(w.scene())
    ex.export(fileName=tempfilename)
    # clean up after the test is done
    os.unlink(tempfilename) 
Example #6
Source File: test_svg.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 6 votes vote down vote up
def test_plotscene():
    tempfilename = tempfile.NamedTemporaryFile(suffix='.svg').name
    print("using %s as a temporary file" % tempfilename)
    pg.setConfigOption('foreground', (0,0,0))
    w = pg.GraphicsWindow()
    w.show()        
    p1 = w.addPlot()
    p2 = w.addPlot()
    p1.plot([1,3,2,3,1,6,9,8,4,2,3,5,3], pen={'color':'k'})
    p1.setXRange(0,5)
    p2.plot([1,5,2,3,4,6,1,2,4,2,3,5,3], pen={'color':'k', 'cosmetic':False, 'width': 0.3})
    app.processEvents()
    app.processEvents()
    
    ex = pg.exporters.SVGExporter(w.scene())
    ex.export(fileName=tempfilename)
    # clean up after the test is done
    os.unlink(tempfilename) 
Example #7
Source File: logic.py    From Calculator_pyqt with MIT License 6 votes vote down vote up
def clicked(self):
	l = float(self.edit1.text())
	r = float(self.edit2.text())
	s = float(self.edit3.text())
	x = np.arange(l,r,s)
	print(x)
	s = calculator_class.var
	print("In Second")
	print(s)
	y = eval(s)
	pg.setConfigOption('background', 'w')      # sets background white
    	pg.setConfigOption('foreground', 'k')      # sets axis color to black
	pw = pg.plot(x,y,pen = 'k')
	pw.setTitle('y = f(x)')
   	pw.setLabel('bottom', 'x -->')           	# x-label
    	pw.setLabel('left', 'y = f(x) -->')             # y-label 
Example #8
Source File: go.py    From Python-GUI-examples with MIT License 5 votes vote down vote up
def __init__(self, parent=None):
        pyqtgraph.setConfigOption('background', 'w') #before loading widget
        super(ExampleApp, self).__init__(parent)
        self.setupUi(self)
        self.grFFT.plotItem.showGrid(True, True, 0.7)
        self.grPCM.plotItem.showGrid(True, True, 0.7)
        self.maxFFT=0
        self.maxPCM=0
        self.ear = SWHear.SWHear(rate=44100,updatesPerSecond=20)
        self.ear.stream_start() 
Example #9
Source File: go.py    From Python-GUI-examples with MIT License 5 votes vote down vote up
def __init__(self, parent=None):
        pyqtgraph.setConfigOption('background', 'w') #before loading widget
        super(ExampleApp, self).__init__(parent)
        self.setupUi(self)
        self.btnAdd.clicked.connect(self.update)
        self.grPlot.plotItem.showGrid(True, True, 0.7) 
Example #10
Source File: twiss_plot.py    From ocelot with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        
        pg.setConfigOptions(antialias=True)
        self.twiss_plot = pg.GraphicsLayoutWidget()

        # Switch to using white background and black foreground
        #pg.setConfigOption('background', 'w')
        #pg.setConfigOption('foreground', 'k')

        self.plot_disp_x = self.twiss_plot.addPlot(row=0, col=0)
        self.plot_disp_x.showGrid(x=True, y=True)

        self.plot_beta = self.twiss_plot.addPlot(row=1, col=0)
        self.plot_beta.showGrid(x=True, y=True)

        self.plot_lattice = self.twiss_plot.addPlot(row=3, col=0)
        self.plot_lattice.showGrid(x=False, y=False)
        #self.plot_lattice.hideAxis('left')
        self.plot_lattice.setMenuEnabled(enableMenu=False)

        self.plot_disp_x.setXLink(self.plot_lattice)
        self.plot_disp_x.addLegend()
        self.plot_beta.setXLink(self.plot_lattice)
        self.plot_beta.addLegend()

        color_blue = QtGui.QColor(0, 0, 255)
        color_red = QtGui.QColor(255, 0, 0)
        color_aqua = QtGui.QColor(0, 255, 255)
        
        pen_blue = pg.mkPen(color_blue, width=2)
        pen_red = pg.mkPen(color_red, width=2)
        pen_aqua = pg.mkPen(color_aqua, width=2)

        self.curv1 = self.plot_disp_x.plot(pen=pen_aqua, name='Dx')
        self.curv2 = self.plot_beta.plot(pen=pen_aqua, name='betaX')
        self.curv3 = self.plot_beta.plot(pen=pen_red, name='betaY') 
Example #11
Source File: main.py    From asammdf with GNU Lesser General Public License v3.0 5 votes vote down vote up
def set_plot_background(self, option):
        self._settings.setValue("plot_background", option)
        if option == "Black":
            pg.setConfigOption("background", "k")
            pg.setConfigOption("foreground", "w")
        else:
            pg.setConfigOption("background", "w")
            pg.setConfigOption("foreground", "k") 
Example #12
Source File: plot_standalone.py    From asammdf with GNU Lesser General Public License v3.0 5 votes vote down vote up
def set_plot_background(self, option):
        self._settings.setValue("plot_background", option)
        if option == "Black":
            pg.setConfigOption("background", "k")
            pg.setConfigOption("foreground", "w")
        else:
            pg.setConfigOption("background", "w")
            pg.setConfigOption("foreground", "k") 
Example #13
Source File: UIGraph.py    From Astibot with MIT License 4 votes vote down vote up
def initializeGraphWidgets(self):
        
        pg.setConfigOption('foreground', 'w')
        pg.setConfigOption('background', (32, 48, 68))
        pg.GraphicsLayout(border=(100,100,100))
        
        self.strPlot1Title = str(self.theSettings.SETT_GetSettings()["strTradingPair"]) + ' Coinbase Pro Market Price (' + str(self.theSettings.SETT_GetSettings()["strFiatType"]) + ')'
        self.plot1 = pg.PlotWidget(title=self.strPlot1Title, axisItems={'bottom': TimeAxisItem(orientation='bottom')})        
        self.plot1.setYRange(self.minInPlot1, self.maxInPlot1)
        self.plot1.setMouseEnabled(False, False) # Mettre False, True pour release
        self.plot1.setMenuEnabled(False)
        axis = self.plot1.getAxis('bottom')  # This is the trick
        axis.setStyle(textFillLimits = [(0, 0.7)])
        
        #self.plot1.plotItem.vb.setBackgroundColor((15, 25, 34, 255))
        self.plot2 = pg.PlotWidget(title='Astibot decision indicator (normalized)')
        self.plot2.showGrid(x=True,y=True,alpha=0.1)
        self.plot2.setYRange(-100, 100)
        self.plot2.setMouseEnabled(False, True)
        self.plot2.setMouseEnabled(False)
        self.plot2.hideAxis('bottom')
        
        # Graphs take one row but 2 columns
        self.mainGridLayout.addWidget(self.plot1, 9, 1, 1, 2)
        self.mainGridLayout.addWidget(self.plot2, 10, 1, 1, 2)
   
        # Graph curves initialization
        self.plot1GraphLivePrice = self.plot1.plot(x=self.graphDataTime, y=self.graphDataBitcoinPrice, name='     Price') # , clipToView=True
        self.plot1GraphLivePrice.setPen(color=(220,220,220), width=3)
        self.plot1GraphSmoothPriceFast = self.plot1.plot(x=self.graphDataTime, y=self.graphDataBitcoinPriceSmoothFast, name='    Price Fast MA')
        self.plot1GraphSmoothPriceFast.setPen(color=(3,86,243), width=2)
        self.plot1GraphSmoothPriceSlow = self.plot1.plot(x=self.graphDataTime, y=self.graphDataBitcoinPriceSmoothSlow, name='    Price Slow MA')
        self.plot1GraphSmoothPriceSlow.setPen(color=(230,79,6), width=2)        
        self.plot1GraphRiskLine = self.plot1.plot(x=self.graphDataTime, y=self.graphDataBitcoinRiskLine, name='    Risk Line')
        self.plot1GraphRiskLine.setPen(color=(255,46,46), width=2, style=QtCore.Qt.DotLine) 
        self.plot1Markers1 = self.plot1.plot(x=self.graphDataTime, y=self.graphDataBitcoinPriceMarker1, name='      Buy', pen=None, symbol='o', symbolPen=(43, 206, 55), symbolBrush=(43, 206, 55), symbolSize = 30)
        self.plot1Markers2 = self.plot1.plot(x=self.graphDataTime, y=self.graphDataBitcoinPriceMarker2, name='      Sell', pen=None, symbol='o', symbolPen=(255, 0, 0), symbolBrush=(255, 0, 0), symbolSize = 30)
 
        # Graph 2 (Indicators) curves initialization
        self.plot2GraphIndicatorMACD = self.plot2.plot(x=self.graphDataTime, y=self.graphDataIndicatorMACD, pen='y', name='     MACD')
   
        self.graphicObject = pg.GraphicsObject()