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

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

项目:NeoAnalysis    作者:neoanalysis    | 项目源码 | 文件源码
def test_PlotCurveItem():
    p = pg.GraphicsWindow()
    p.ci.layout.setContentsMargins(4, 4, 4, 4)  # default margins vary by platform
    v = p.addViewBox()
    p.resize(200, 150)
    data = np.array([1,4,2,3,np.inf,5,7,6,-np.inf,8,10,9,np.nan,-1,-2,0])
    c = pg.PlotCurveItem(data)
    v.addItem(c)
    v.autoRange()

    # Check auto-range works. Some platform differences may be expected..
    checkRange = np.array([[-1.1457564053237301, 16.145756405323731], [-3.076811473165955, 11.076811473165955]])
    assert np.allclose(v.viewRange(), checkRange)

    assertImageApproved(p, 'plotcurveitem/connectall', "Plot curve with all points connected.")

    c.setData(data, connect='pairs')
    assertImageApproved(p, 'plotcurveitem/connectpairs', "Plot curve with pairs connected.")

    c.setData(data, connect='finite')
    assertImageApproved(p, 'plotcurveitem/connectfinite', "Plot curve with finite points connected.")

    c.setData(data, connect=np.array([1,1,1,0,1,1,0,0,1,0,0,0,1,1,0,0]))
    assertImageApproved(p, 'plotcurveitem/connectarray', "Plot curve with connection array.")
项目:NeoAnalysis    作者:neoanalysis    | 项目源码 | 文件源码
def init_viewbox():
    """Helper function to init the ViewBox
    """
    global win, vb

    win = pg.GraphicsWindow()
    win.ci.layout.setContentsMargins(0,0,0,0)
    win.resize(200, 200)
    win.show()
    vb = win.addViewBox()

    # set range before viewbox is shown
    vb.setRange(xRange=[0, 10], yRange=[0, 10], padding=0)

    # required to make mapFromView work properly.
    qtest.qWaitForWindowShown(win)

    g = pg.GridItem()
    vb.addItem(g)

    app.processEvents()
项目:NeoAnalysis    作者:neoanalysis    | 项目源码 | 文件源码
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)
项目:NeoAnalysis    作者:neoanalysis    | 项目源码 | 文件源码
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)
项目:pyrpl    作者:lneuhaus    | 项目源码 | 文件源码
def init_gui(self):
        #self.main_layout = QtWidgets.QVBoxLayout(self)
        self.init_main_layout(orientation="vertical")
        self.init_attribute_layout()

        self.win = pg.GraphicsWindow(title="Expected signal")
        self.plot_item = self.win.addPlot(title='Expected ' + self.module.name)
        self.plot_item.showGrid(y=True, x=True, alpha=1.)
        self.curve = self.plot_item.plot(pen='y')
        self.curve_slope = self.plot_item.plot(pen=pg.mkPen('b', width=5))
        self.symbol = self.plot_item.plot(pen='b', symbol='o')
        self.main_layout.addWidget(self.win)
        self.button_calibrate = QtWidgets.QPushButton('Calibrate')
        self.main_layout.addWidget(self.button_calibrate)
        self.button_calibrate.clicked.connect(lambda: self.module.calibrate())
        self.input_calibrated()
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def plot_liss(self):
        lissx = self.Liss_x.currentText()
        lissy = self.Liss_y.currentText()
        self.liss_x = self.Liss_x.currentIndex()
        self.liss_y = self.Liss_y.currentIndex()
        if not (self.channel_states[self.liss_x] and self.channel_states[self.liss_y]):
            QtGui.QMessageBox.about(self, 'Error : Insufficient Data',  'Please enable the selected channels in the oscilloscope')
            return

        self.liss_win = pg.GraphicsWindow(title="Basic plotting examples")
        self.liss_win.setWindowTitle('pyqtgraph example: Plotting')
        self.p1 = self.liss_win.addPlot(title="Lissajous: x : %s vs y : %s"%(lissx,lissy),x=self.I.achans[self.liss_x].get_yaxis(),y=self.I.achans[self.liss_y].get_yaxis())
        self.p1.setLabel('left',lissy);self.p1.setLabel('bottom',lissx)
        self.p1.getAxis('left').setGrid(170)
        self.p1.getAxis('bottom').setGrid(170)

        self.lissvLine = pg.InfiniteLine(angle=90, movable=False,pen=[100,100,200,200])
        self.p1.addItem(self.lissvLine, ignoreBounds=True)
        self.lisshLine = pg.InfiniteLine(angle=0, movable=False,pen=[100,100,200,200])
        self.p1.addItem(self.lisshLine, ignoreBounds=True)
        self.vb = self.p1.vb
        self.lissproxy = pg.SignalProxy(self.p1.scene().sigMouseClicked, rateLimit=60, slot=self.lissMouseClicked)
项目:ANNarchy    作者:vitay    | 项目源码 | 文件源码
def __init__(self, video, result):
        self.video = video
        self.result = result
        app = pg.mkQApp()
        self.win = pg.GraphicsWindow(title="Live webcam")
        self.win.resize(640,480)   

        box = self.win.addViewBox(lockAspect=True)
        box.invertY()
        self.vis = pg.ImageItem()
        box.addItem(self.vis)  

        box = self.win.addViewBox(lockAspect=True)
        box.invertY()
        self.res = pg.ImageItem()
        box.addItem(self.res)  

        self.win.show()

        self.lastUpdate = pg.ptime.time()
        self.avgFps = 0.0
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addCompSpecPlot(self, title, sim, comp_id, spec_id, data_size = 1000, x_range = None, y_range = None, measure = "count", **kwargs):
        """
        Add plot to display the amount changes of species in a compartment.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * comp_id         ID of the compartment
            * spec_id         ID of the species
            * data_size       Size of the data history
            * x_range         Range of X axis
            * y_range         Range of y axis
            * measure         Measure type
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = CompSpecUpdater(plot, sim, comp_id, spec_id, data_size, x_range, y_range, measure, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addTetsSpecPlot(self, title, sim, tets, spec_id, data_size = 1000, x_range = None, y_range = None, measure = "count", **kwargs):
        """
        Add plot to display the amount changes of species in a list of tetrahedrons.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * tets            List of tetrahedron indices
            * spec_id         ID of the species
            * data_size       Size of the data history
            * x_range         Range of X axis
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = TetsSpecUpdater(plot, sim, tets, spec_id, data_size, x_range, y_range, measure, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addPatchSpecPlot(self, title, sim, patch_id, spec_id, data_size = 1000, x_range = None, y_range = None, **kwargs):
        """
        Add plot to display the amount changes of species in a patch.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * patch_id        ID of the patch
            * spec_id         ID of the species
            * data_size       Size of the data history
            * x_range         Range of X axis
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = PatchSpecUpdater(plot, sim, patch_id, spec_id, data_size, x_range, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addTrisSpecPlot(self, title, sim, tris, spec_id, data_size = 1000, x_range = None, y_range = None, **kwargs):
        """
        Add plot to display the amount changes of species in a list of triangles.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * tris            List of triangle indices
            * spec_id         ID of the species
            * data_size       Size of the data history
            * x_range         Range of X axis
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = TrisSpecUpdater(plot, sim, tris, spec_id, data_size, x_range, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addPatchSumSpecsPlot(self, title, sim, patch_id, spec_ids, data_size = 1000, x_range = None, y_range = None, **kwargs):
        """
        Add plot to display the sum-up amount changes of species in a patch.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * patch_id        ID of the patch
            * spec_id         ID of the species
            * data_size       Size of the data history
            * x_range         Range of X axis
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = PatchSumSpecsUpdater(plot, sim, patch_id, spec_ids, data_size, x_range, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addCompSpecDist(self, title, mesh, sim, comp_id, spec_id, axis = "x", nbins = 20, y_range = None, **kwargs):
        """
        Add plot to display the distribution of species in a compartment.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * comp_id         ID of the compartment
            * spec_id         ID of the species
            * axis            Spatial direction of the distribution
            * nbins           Number of bins for the data
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = CompSpecDistUpdater(plot, mesh, sim, comp_id, spec_id, axis, nbins, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addPatchSpecDist(self, title, mesh, sim, patch_id, spec_id, axis = "x", nbins = 20, y_range = None, **kwargs):
        """
        Add plot to display the distribution of species in a patch.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * mesh            STEPS mesh
            * patch_id        ID of the patch
            * spec_id         ID of the species
            * axis            Spatial direction of the distribution
            * nbins           Number of bins for the data
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = PatchSpecDistUpdater(plot, mesh, sim, patch_id, spec_id, axis, nbins, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addTetsSpecDist(self, title, mesh, sim, tets, spec_id, axis = "x", nbins = 20, y_range = None, **kwargs):
        """
        Add plot to display the distribution of species in a list of tetrahedrons.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * mesh            STEPS mesh
            * tets            List of tetrahedron indices
            * spec_id         ID of the species
            * axis            Spatial direction of the distribution
            * nbins           Number of bins for the data
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = TetsSpecDistUpdater(plot, mesh, sim, tets, spec_id, axis, nbins, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addTrisSpecDist(self, title, mesh, sim, tris, spec_id, axis = "x", nbins = 20, y_range = None, **kwargs):
        """
        Add plot to display the distribution of species in a list of triangles.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * mesh            STEPS mesh
            * tris            List of triangle indices
            * spec_id         ID of the species
            * axis            Spatial direction of the distribution
            * nbins           Number of bins for the data
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = TrisSpecDistUpdater(plot, mesh, sim, tris, spec_id, axis, nbins, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addCompSpecPlot(self, title, sim, comp_id, spec_id, data_size = 1000, x_range = None, y_range = None, measure = "count", **kwargs):
        """
        Add plot to display the amount changes of species in a compartment.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * comp_id         ID of the compartment
            * spec_id         ID of the species
            * data_size       Size of the data history
            * x_range         Range of X axis
            * y_range         Range of y axis
            * measure         Measure type
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = CompSpecUpdater(plot, sim, comp_id, spec_id, data_size, x_range, y_range, measure, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addTetsSpecPlot(self, title, sim, tets, spec_id, data_size = 1000, x_range = None, y_range = None, measure = "count", **kwargs):
        """
        Add plot to display the amount changes of species in a list of tetrahedrons.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * tets            List of tetrahedron indices
            * spec_id         ID of the species
            * data_size       Size of the data history
            * x_range         Range of X axis
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = TetsSpecUpdater(plot, sim, tets, spec_id, data_size, x_range, y_range, measure, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addPatchSpecPlot(self, title, sim, patch_id, spec_id, data_size = 1000, x_range = None, y_range = None, **kwargs):
        """
        Add plot to display the amount changes of species in a patch.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * patch_id        ID of the patch
            * spec_id         ID of the species
            * data_size       Size of the data history
            * x_range         Range of X axis
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = PatchSpecUpdater(plot, sim, patch_id, spec_id, data_size, x_range, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addTrisSpecPlot(self, title, sim, tris, spec_id, data_size = 1000, x_range = None, y_range = None, **kwargs):
        """
        Add plot to display the amount changes of species in a list of triangles.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * tris            List of triangle indices
            * spec_id         ID of the species
            * data_size       Size of the data history
            * x_range         Range of X axis
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = TrisSpecUpdater(plot, sim, tris, spec_id, data_size, x_range, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addPatchSumSpecsPlot(self, title, sim, patch_id, spec_ids, data_size = 1000, x_range = None, y_range = None, **kwargs):
        """
        Add plot to display the sum-up amount changes of species in a patch.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * patch_id        ID of the patch
            * spec_id         ID of the species
            * data_size       Size of the data history
            * x_range         Range of X axis
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = PatchSumSpecsUpdater(plot, sim, patch_id, spec_ids, data_size, x_range, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addCompSpecDist(self, title, mesh, sim, comp_id, spec_id, axis = "x", nbins = 20, y_range = None, **kwargs):
        """
        Add plot to display the distribution of species in a compartment.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * comp_id         ID of the compartment
            * spec_id         ID of the species
            * axis            Spatial direction of the distribution
            * nbins           Number of bins for the data
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = CompSpecDistUpdater(plot, mesh, sim, comp_id, spec_id, axis, nbins, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addPatchSpecDist(self, title, mesh, sim, patch_id, spec_id, axis = "x", nbins = 20, y_range = None, **kwargs):
        """
        Add plot to display the distribution of species in a patch.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * mesh            STEPS mesh
            * patch_id        ID of the patch
            * spec_id         ID of the species
            * axis            Spatial direction of the distribution
            * nbins           Number of bins for the data
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = PatchSpecDistUpdater(plot, mesh, sim, patch_id, spec_id, axis, nbins, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addTetsSpecDist(self, title, mesh, sim, tets, spec_id, axis = "x", nbins = 20, y_range = None, **kwargs):
        """
        Add plot to display the distribution of species in a list of tetrahedrons.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * mesh            STEPS mesh
            * tets            List of tetrahedron indices
            * spec_id         ID of the species
            * axis            Spatial direction of the distribution
            * nbins           Number of bins for the data
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = TetsSpecDistUpdater(plot, mesh, sim, tets, spec_id, axis, nbins, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def addTrisSpecDist(self, title, mesh, sim, tris, spec_id, axis = "x", nbins = 20, y_range = None, **kwargs):
        """
        Add plot to display the distribution of species in a list of triangles.

        Parameters:
            * title           Title of the plot
            * sim             STEPS solver
            * mesh            STEPS mesh
            * tris            List of triangle indices
            * spec_id         ID of the species
            * axis            Spatial direction of the distribution
            * nbins           Number of bins for the data
            * y_range         Range of y axis
            * **kwargs        Other keywords that are supported by pygraph.GraphicsWindow class

        Return:
            pyqtgraph.PlotItem object
        """
        if title in self.updater:
            raise NameError('A Plot with name ' + title + " exists.")
        plot = self.addPlot(title = title)
        updater = TrisSpecDistUpdater(plot, mesh, sim, tris, spec_id, axis, nbins, y_range, **kwargs)
        self.updater[title] = updater
        return plot
项目:pytelemetrycli    作者:Overdrivr    | 项目源码 | 文件源码
def run(self):
        self.app = QtGui.QApplication([])
        win = pg.GraphicsWindow(title="Basic plotting examples")
        win.resize(1000,600)
        win.setWindowTitle('pyqtgraph example: Plotting')
        plot = win.addPlot(title=self.name)
        self.curve = plot.plot(pen='y')

        timer = QtCore.QTimer()
        timer.timeout.connect(self._update)
        timer.start(50)

        self.app.exec_()
        try:
            self.in_process_pipe.send("closing")
        except:
            pass
            # Process was done, no need to process exception
项目:NeoAnalysis    作者:neoanalysis    | 项目源码 | 文件源码
def test_GraphicsWindow():
    def mkobjs():
        w = pg.GraphicsWindow()
        p1 = w.addPlot()
        v1 = w.addViewBox()
        return mkrefs(w, p1, v1)

    for i in range(5):
        assert_alldead(mkobjs())
项目:NeoAnalysis    作者:neoanalysis    | 项目源码 | 文件源码
def test_PlotCurveItem():
    p = pg.GraphicsWindow()
    p.ci.layout.setContentsMargins(4, 4, 4, 4)  # default margins vary by platform
    v = p.addViewBox()
    p.resize(200, 150)
    data = np.array([1,4,2,3,np.inf,5,7,6,-np.inf,8,10,9,np.nan,-1,-2,0])
    c = pg.PlotCurveItem(data)
    v.addItem(c)
    v.autoRange()

    # Check auto-range works. Some platform differences may be expected..
    checkRange = np.array([[-1.1457564053237301, 16.145756405323731], [-3.076811473165955, 11.076811473165955]])
    assert np.allclose(v.viewRange(), checkRange)

    assertImageApproved(p, 'plotcurveitem/connectall', "Plot curve with all points connected.")

    c.setData(data, connect='pairs')
    assertImageApproved(p, 'plotcurveitem/connectpairs', "Plot curve with pairs connected.")

    c.setData(data, connect='finite')
    assertImageApproved(p, 'plotcurveitem/connectfinite', "Plot curve with finite points connected.")

    c.setData(data, connect=np.array([1,1,1,0,1,1,0,0,1,0,0,0,1,1,0,0]))
    assertImageApproved(p, 'plotcurveitem/connectarray', "Plot curve with connection array.")
项目:NeoAnalysis    作者:neoanalysis    | 项目源码 | 文件源码
def test_GraphicsWindow():
    def mkobjs():
        w = pg.GraphicsWindow()
        p1 = w.addPlot()
        v1 = w.addViewBox()
        return mkrefs(w, p1, v1)

    for i in range(5):
        assert_alldead(mkobjs())
项目:pyrpl    作者:lneuhaus    | 项目源码 | 文件源码
def __init__(self, title="plotwindow"):
        self.win = pg.GraphicsWindow(title=title)
        self.pw = self.win.addPlot()
        self.curves = {}
        self.win.show()
        self.plot_start_time = time()
项目:pyrpl    作者:lneuhaus    | 项目源码 | 文件源码
def _make_widget(self):
        """
        Sets the widget (here a QCheckbox)
        :return:
        """
        self.widget = pg.GraphicsWindow(title="Plot")
        legend = getattr(self.module.__class__, self.attribute_name).legend
        self.pw = self.widget.addPlot(title="%s vs. time (s)"%legend)
        self.plot_start_time = self.time()
        self.curves = {}
        setattr(self.module.__class__, '_' + self.attribute_name + '_pw', self.pw)
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def newPlot(self,x,y,**args):
        self.plot_ext = pg.GraphicsWindow(title=args.get('title',''))
        self.curve_ext = self.plot_ext.addPlot(title=args.get('title',''), x=x,y=y,connect='finite')
        self.curve_ext.setLabel('bottom',args.get('xLabel',''))
        self.curve_ext.setLabel('left',args.get('yLabel',''))
项目:ANNarchy    作者:vitay    | 项目源码 | 文件源码
def __init__(self, func):

        self.func = func

        app = pg.mkQApp()
        self.win = pg.GraphicsWindow(title="Bar learning")
        self.win.resize(800,800)
        self.win.addLabel("Input")
        self.win.addLabel("Feature")
        self.win.nextRow()

        box = self.win.addViewBox(lockAspect=True)
        self.input_vis = pg.ImageItem()
        box.addItem(self.input_vis)

        box = self.win.addViewBox(lockAspect=True)
        self.feature_vis = pg.ImageItem()
        box.addItem(self.feature_vis)
        self.win.nextRow()

        self.win.addLabel("Receptive fields", colspan=2)
        self.win.nextRow()
        box = self.win.addViewBox(lockAspect=True, colspan=2)
        self.rv_vis = pg.ImageItem()
        box.addItem(self.rv_vis)

        self.win.show()
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def __init__(self, title=None, size=(800, 600)):
        """
        Constructor.
        """
        pg.GraphicsWindow.__init__(self, title=title, size=size)
        self.updater = {}
项目:STEPS    作者:CNS-OIST    | 项目源码 | 文件源码
def __init__(self, title=None, size=(800, 600)):
        """
        Constructor.
        """
        pg.GraphicsWindow.__init__(self, title=title, size=size)
        self.updater = {}
项目:pyrpl    作者:lneuhaus    | 项目源码 | 文件源码
def init_gui(self):
        """
        Sets up the gui.
        """
        self.ch_col = ('magenta', 'blue', 'green')
        self.last_data = None
        self.init_main_layout(orientation="vertical")
        #self.main_layout = QtWidgets.QVBoxLayout()
        self.module.__dict__['curve_name'] = 'pyrpl spectrum'
        self.init_attribute_layout()

        self.other_widget = OtherAttributesWidget(self)
        self.attribute_layout.addWidget(self.other_widget)

        self.iqmode_widget = IqModeAttributesWidget(self)
        self.attribute_layout.addWidget(self.iqmode_widget)

        self.baseband_widget = BasebandAttributesWidget(self)
        self.attribute_layout.addWidget(self.baseband_widget)


        self.button_layout = QtWidgets.QHBoxLayout()
        self.setLayout(self.main_layout)
        # self.setWindowTitle("Spec. An.")
        #self.win = pg.GraphicsWindow(title="PSD")
        #self.main_layout.addWidget(self.win)

        self.win2 = DataWidget(title='Spectrum')
        self.main_layout.addWidget(self.win2)

        #self.plot_item = self.win.addPlot(title="PSD")
        #self.curve = self.plot_item.plot(pen=self.ch_col[0][0])

        #self.curve2 = self.plot_item.plot(pen=self.ch_col[1][0]) # input2
        # spectrum in
        # baseband
        #self.curve_cross = self.plot_item.plot(pen=self.ch_col[2][0]) #
        # curve for


        super(SpecAnWidget, self).init_gui()

        aws = self.attribute_widgets


        aws['display_input1_baseband'].setStyleSheet("color: %s" %
                                                   self.ch_col[0])
        aws['display_input2_baseband'].setStyleSheet("color: %s" %
                                                   self.ch_col[1])
        aws['display_cross_amplitude'].setStyleSheet("color: %s" %
                                                   self.ch_col[2])
        # Not sure why the stretch factors in button_layout are not good by
        # default...

        self.attribute_layout.addStretch(1)
        self.update_baseband_visibility()
项目:pyrpl    作者:lneuhaus    | 项目源码 | 文件源码
def _make_widget(self):
        self.widget = pg.GraphicsWindow(title="Curve")
        self.plot_item = self.widget.addPlot(title="Curve")
        self.plot_item_phase = self.widget.addPlot(row=1, col=0, title="Phase (deg)")
        self.plot_item_phase.setXLink(self.plot_item)
        self.plot_item.showGrid(y=True, alpha=1.)
        self.plot_item_phase.showGrid(y=True, alpha=1.)
        self.curve = self.plot_item.plot(pen='g')
        self.curve_phase = self.plot_item_phase.plot(pen='g')
        self._is_real = True
        self._set_real(True)

    #def _set_widget_value(self, new_value):
    #   data = new_value
    #    if data is None:
    #        return
    #    shape = np.shape(new_value)
    #    if len(shape)>2:
    #        raise ValueError("Shape of data should be (1) or (2, 1)")
    #    if len(shape)==1:
    #        x = np.linspace(0, len(data), len(data))
    #        y = [data]
    #    if len(shape)==2:
    #        if shape[0] == 1:
    #            x = np.linspace(0, len(data), len(data[0]))
    #            y = [data[0]]
    #        if shape[0] >= 2:
    #            x = data[0]
    #            y = data[1:]
    #    self._set_real(np.isreal(y).all())
    #    for i, values in enumerate(y):
    #        self._display_curve_index(x, values, i)
    #    while (i + 1 < len(self.curves)):  # delete remaining curves
    #        i += 1
    #        self.curves[i].hide()

    #def _display_curve_index(self, x, values, i):
    #    y_mag = values if self._is_real else self._magnitude(values)
    #    y_phase = np.zeros(len(values)) if self._is_real else \
    #        self._phase(values)
    #    if len(self.curves)<=i:
    #        color = self._defaultcolors[i%len(self._defaultcolors)]
    #        self.curves.append(self.plot_item.plot(pen=color))
    #        self.curves_phase.append(self.plot_item_phase.plot(pen=color))
    #    self.curves[i].setData(x, y_mag)
    #    self.curves_phase[i].setData(x, y_phase)