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

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

项目:CElegansBehaviour    作者:ChristophKirst    | 项目源码 | 文件源码
def __init__(self, data, title = None, color = 'viridis', ncolors = None):
    #self.app = pg.QtGui.QApplication([])
    #self.win = pg.GraphicsLayoutWidget()
    #self.win.resize(1200, 800)
    lut = colormap_lut(color, ncolors);

    self.img = pg.ImageItem()
    self.img.setLookupTable(lut)
    self.img.setLevels([0,1])        

    #self.plot = self.win.addPlot()
    self.plot = pg.plot(title = title);
    self.plot.addItem(self.img)

    #self.timer = QtCore.QTimer()
    #self.timer.timeout.connect(self.check_for_new_data_and_replot)
    #self.timer.start(100)
    self.img.setImage(data.T)
    #self.win.show()
项目:CElegansBehaviour    作者:ChristophKirst    | 项目源码 | 文件源码
def __init__(self, data, title = None, color = 'viridis', ncolors = None):
    #self.app = pg.QtGui.QApplication([])
    #self.win = pg.GraphicsLayoutWidget()
    #self.win.resize(1200, 800)
    lut = colormap_lut(color, ncolors);

    self.img = pg.ImageItem()
    self.img.setLookupTable(lut)
    self.img.setLevels([0,1])        

    #self.plot = self.win.addPlot()
    self.plot = pg.plot(title = title);
    self.plot.addItem(self.img)

    #self.timer = QtCore.QTimer()
    #self.timer.timeout.connect(self.check_for_new_data_and_replot)
    #self.timer.start(100)
    self.img.setImage(data.T)
    #self.win.show()
项目:FoundryDataBrowser    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):
        HyperSpectralBaseView.setup(self)
        TRPLNPZView.scan_specific_setup(self)

        self.settings.New('plane', dtype=str, initial='xy', choices=('xy', 'yz', 'xz'))
        self.settings.New('index', dtype=int)
        self.settings.New('auto_level', dtype=bool, initial=True)
        for name in ['plane', 'index', 'auto_level']:
            self.settings.get_lq(name).add_listener(self.update_display)

        #self.ui = QtWidgets.QWidget()
        #self.ui.setLayout(QtWidgets.QVBoxLayout())
        self.dockarea.addDock(name='Image', widget=self.settings.New_UI())
        self.info_label = QtWidgets.QLabel()
        self.dockarea.addDock(name='info', widget=self.info_label)
        #self.imview = pg.ImageView()
        #self.ui.layout().addWidget(self.imview, stretch=1)

        #self.graph_layout = pg.GraphicsLayoutWidget()
        #self.graph_layout.addPlot()
项目:FoundryDataBrowser    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):

        self.settings.New('plane', dtype=str, initial='xy', choices=('xy', 'yz', 'xz'))
        self.settings.New('index', dtype=int)
        self.settings.New('auto_level', dtype=bool, initial=True)
        for name in ['plane', 'index', 'auto_level']:
            self.settings.get_lq(name).add_listener(self.update_display)

        self.ui = QtWidgets.QWidget()
        self.ui.setLayout(QtWidgets.QVBoxLayout())
        self.ui.layout().addWidget(self.settings.New_UI(), stretch=0)
        self.info_label = QtWidgets.QLabel()
        self.ui.layout().addWidget(self.info_label, stretch=0)
        self.imview = pg.ImageView()
        self.ui.layout().addWidget(self.imview, stretch=1)

        #self.graph_layout = pg.GraphicsLayoutWidget()
        #self.graph_layout.addPlot()
项目:FoundryDataBrowser    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):

        self.settings.New('frame', dtype=int)
        self.settings.New('sub_frame', dtype=int)
        self.settings.New('channel', dtype=str, choices=('ai0', 'ai1', 'ctr0', 'ctr1'))
        self.settings.New('auto_level', dtype=bool, initial=True)
        for name in ['frame', 'sub_frame','channel', 'auto_level']:
            self.settings.get_lq(name).add_listener(self.update_display)

        self.ui = QtWidgets.QWidget()
        self.ui.setLayout(QtWidgets.QVBoxLayout())
        self.ui.layout().addWidget(self.settings.New_UI(), stretch=0)
        self.info_label = QtWidgets.QLabel()
        self.ui.layout().addWidget(self.info_label, stretch=0)
        self.imview = pg.ImageView()
        self.ui.layout().addWidget(self.imview, stretch=1)

        #self.graph_layout = pg.GraphicsLayoutWidget()
        #self.graph_layout.addPlot()
项目:FoundryDataBrowser    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):

        self.ui = self.graph_layout = pg.GraphicsLayoutWidget()
        self.plot = self.graph_layout.addPlot(title="Andor CCD Spectrum")

        self.plotline = self.plot.plot()
项目:FoundryDataBrowser    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):

        self.ui = self.graph_layout = pg.GraphicsLayoutWidget()
        self.plot = self.graph_layout.addPlot()
        self.plotdata = self.plot.plot(pen='r')
        self.plot.setLogMode(False, True)
项目: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.settings.New("x_axis", dtype=str, initial='power_wheel', choices=('power_wheel', 'pm_power'))

        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.ui.x_axis_comboBox = QtWidgets.QComboBox()
        self.settings.x_axis.connect_to_widget(self.ui.x_axis_comboBox)
        self.ui.layout().addWidget(self.ui.x_axis_comboBox)

        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])

        self.power_plot_current_pos = self.power_plot.plot(symbol='o')
        #self.power_plot_arrow = pg.ArrowItem()
        #self.power_plot_arrow.setPos(0,0)
        #self.power_plot.addItem(self.power_plot_arrow)

        self.graph_layout.nextRow()

        self.spec_plot = self.graph_layout.addPlot()
        self.spec_plotcurve = self.spec_plot.plot([0])
项目:FoundryDataBrowser    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):

        self.ui = self.imview = pg.ImageView()

        #self.graph_layout = pg.GraphicsLayoutWidget()
        #self.graph_layout.addPlot()
项目:FoundryDataBrowser    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):

        self.ui = self.graph_layout = pg.GraphicsLayoutWidget()
        self.plot = self.graph_layout.addPlot()
        self.plotdata = self.plot.plot()
项目:FoundryDataBrowser    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):

        self.ui = self.graph_layout = pg.GraphicsLayoutWidget()
        self.plot = self.graph_layout.addPlot(title="Auger Spectrum")

        self.display_chans = 7
        self.plot_setup()
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def resizeEvent(self, ev):
        pg.GraphicsLayoutWidget.resizeEvent(self, ev)
        if hasattr(self, 'plots'):
            viewbox = self.plots[0].getViewBox()
            viewbox.autoRange()
项目:ScopeFoundry    作者:ScopeFoundry    | 项目源码 | 文件源码
def setup(self):

        #self.ui = self.splitter = QtWidgets.QSplitter()
        #self.ui.setLayout(QtWidgets.QVBoxLayout())
        self.ui = self.dockarea = dockarea.DockArea()
        self.imview = pg.ImageView()
        self.imview.getView().invertY(False) # lower left origin
        #self.splitter.addWidget(self.imview)
        self.dockarea.addDock(name='Image', widget=self.imview)
        self.graph_layout = pg.GraphicsLayoutWidget()
        #self.splitter.addWidget(self.graph_layout)
        self.dockarea.addDock(name='Spec Plot', widget=self.graph_layout)

        self.spec_plot = self.graph_layout.addPlot()
        self.rect_plotdata = self.spec_plot.plot()
        self.point_plotdata = self.spec_plot.plot(pen=(0,9))


        # Rectangle ROI
        self.rect_roi = pg.RectROI([20, 20], [20, 20], pen=(0,9))
        self.rect_roi.addTranslateHandle((0.5,0.5))        
        self.imview.getView().addItem(self.rect_roi)        
        self.rect_roi.sigRegionChanged[object].connect(self.on_change_rect_roi)

        # Point ROI
        self.circ_roi = pg.CircleROI( (0,0), (2,2) , movable=True, pen=(0,9))
        #self.circ_roi.removeHandle(self.circ_roi.getHandles()[0])
        h = self.circ_roi.addTranslateHandle((0.5,.5))
        h.pen = pg.mkPen('r')
        h.update()
        self.imview.getView().addItem(self.circ_roi)
        self.circ_roi.removeHandle(0)
        self.circ_roi_plotline = pg.PlotCurveItem([0], pen=(0,9))
        self.imview.getView().addItem(self.circ_roi_plotline) 
        self.circ_roi.sigRegionChanged[object].connect(self.on_update_circ_roi)

        self.hyperspec_data = None
        self.display_image = None
        self.spec_x_array = None

        self.scan_specific_setup()
项目:ScopeFoundry    作者:ScopeFoundry    | 项目源码 | 文件源码
def add_pg_graphics_layout(self, name, widget):
        self.log.info("---adding pg GraphicsLayout figure {} {}".format( name, widget))
        if name in self.figs:
            return self.figs[name]
        else:
            disp=pg.GraphicsLayoutWidget(border=(100,100,100))
            widget.layout().addWidget(disp)
            self.figs[name]=disp
            return disp

        # IDEA: write an abstract function to add pg.imageItem() for maps, 
        # which haddels, pixelscale, ROI ....
        # could also be implemented in the base_2d class? 



#     def add_figure_mpl(self,name, widget):
#         """creates a matplotlib figure attaches it to the qwidget specified
#         (widget needs to have a layout set (preferably verticalLayout) 
#         adds a figure to self.figs"""
#         print "---adding figure", name, widget
#         if name in self.figs:
#             return self.figs[name]
#         else:
#             fig = Figure()
#             fig.patch.set_facecolor('w')
#             canvas = FigureCanvas(fig)
#             nav    = NavigationToolbar2(canvas, self.ui)
#             widget.layout().addWidget(canvas)
#             widget.layout().addWidget(nav)
#             canvas.setFocusPolicy( QtCore.Qt.ClickFocus )
#             canvas.setFocus()
#             self.figs[name] = fig
#             return fig
项目:ConvNetQuake    作者:tperol    | 项目源码 | 文件源码
def set_graphics_view(self):
    self.win = pg.GraphicsLayoutWidget()
    self.layout.addWidget(self.win)

    self.trace_x = self.win.addPlot(title="X")
    self.win.nextRow()
    self.trace_y = self.win.addPlot(title="Y")
    self.trace_y.setXLink(self.trace_x)
    self.trace_y.setYLink(self.trace_x)
    self.win.nextRow()
    self.trace_z = self.win.addPlot(title="Z")
    self.trace_z.setXLink(self.trace_x)
    self.trace_z.setYLink(self.trace_x)
项目: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])
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, sandbox, *args, **kwargs):
        pg.GraphicsLayoutWidget.__init__(self, **kwargs)
        self.sandbox = sandbox

        self.plots = [
            DisplacementPlot(
                sandbox,
                title='North',
                component=lambda m: m.north),
            DisplacementPlot(
                sandbox,
                title='East',
                component=lambda m: m.east),
            DisplacementVectorPlot(
                sandbox,
                title='Down',
                component=lambda m: m.down),
            DisplacementPlot(
                sandbox,
                title='LOS',
                component=lambda m: m.displacement)]
        self.plots[-1].addHintText()

        self._mov_sig = pg.SignalProxy(
            self.scene().sigMouseMoved,
            rateLimit=60, slot=self.mouseMoved)

        for ip, plt in enumerate(self.plots):
            row = ip / 2
            col = ip % 2 + 1

            self.addItem(plt, row=row, col=col)
            plt.showGrid(x=True, y=True)
            plt.hideAxis('bottom')
            plt.hideAxis('left')
            plt.vb.border = pg.mkPen(50, 50, 50)
            if ip != 0:
                plt.setXLink(self.plots[0])
                plt.setYLink(self.plots[0])

        def getAxis(plt, orientation, label):
            axis = pg.AxisItem(
                orientation=orientation,
                linkView=plt.vb)
            axis.setLabel(label, units='m')
            return axis

        plts = self.plots
        self.addItem(getAxis(plts[0], 'left', 'Northing'), row=0, col=0)
        self.addItem(getAxis(plts[1], 'left', 'Northing'), row=1, col=0)
        self.addItem(getAxis(plts[0], 'bottom', 'Easting'), row=2, col=1)
        self.addItem(getAxis(plts[1], 'bottom', 'Easting'), row=2, col=2)

        for plt in self.plots:
            plt.vb.menu = QtGui.QMenu(self)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, sandbox, *args, **kwargs):
        pg.GraphicsLayoutWidget.__init__(self, **kwargs)
        self.sandbox = sandbox

        self.plots = [
            DisplacementPlot(
                sandbox,
                title='Scene Displacement',
                component=lambda m: m.reference.scene.displacement),
            DisplacementPlot(
                sandbox,
                title='Model Residual',
                component=lambda m: m.reference.difference)]
        self.plots[-1].addHintText()

        self._mov_sig = pg.SignalProxy(
            self.scene().sigMouseMoved,
            rateLimit=60, slot=self.mouseMoved)

        for ip, plt in enumerate(self.plots):
            row = ip / 2
            col = ip % 2 + 1

            self.addItem(plt, row=row, col=col)
            plt.showGrid(x=True, y=True)
            plt.hideAxis('bottom')
            plt.hideAxis('left')
            plt.vb.border = pg.mkPen(50, 50, 50)
            if ip != 0:
                plt.setXLink(self.plots[0])
                plt.setYLink(self.plots[0])

        def getAxis(plt, orientation, label):
            axis = pg.AxisItem(
                orientation=orientation,
                linkView=plt.vb)
            axis.setLabel(label, units='m')
            return axis

        plts = self.plots
        self.addItem(getAxis(plts[0], 'left', 'Northing'), row=0, col=0)
        self.addItem(getAxis(plts[1], 'left', 'Northing'), row=1, col=0)
        self.addItem(getAxis(plts[0], 'bottom', 'Easting'), row=2, col=1)
        self.addItem(getAxis(plts[1], 'bottom', 'Easting'), row=2, col=2)