Python pyqtgraph.ImageItem() Examples

The following are 23 code examples of pyqtgraph.ImageItem(). 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: onlinewaveformhistviewer.py    From tridesclous with MIT License 6 votes vote down vote up
def initialize_plot(self):
        
        self.viewBox = MyViewBox()
        self.viewBox.doubleclicked.connect(self.open_settings)
        self.viewBox.gain_zoom.connect(self.gain_zoom)
        self.viewBox.disableAutoRange()
        
        self.plot = pg.PlotItem(viewBox=self.viewBox)
        self.graphicsview.setCentralItem(self.plot)
        self.plot.hideButtons()
        
        self.image = pg.ImageItem()
        self.plot.addItem(self.image)
        
        self.curve_spike = pg.PlotCurveItem()
        self.plot.addItem(self.curve_spike)

        self.curve_limit = pg.PlotCurveItem()
        self.plot.addItem(self.curve_limit)
        
        self.change_lut() 
Example #2
Source File: similarity.py    From tridesclous with MIT License 6 votes vote down vote up
def initialize_plot(self):
        self.viewBox = MyViewBox()
        self.viewBox.doubleclicked.connect(self.open_settings)
        self.viewBox.disableAutoRange()
        
        self.plot = pg.PlotItem(viewBox=self.viewBox)
        self.graphicsview.setCentralItem(self.plot)
        self.plot.hideButtons()
        
        self.image = pg.ImageItem()
        self.plot.addItem(self.image)
        
        self.plot.hideAxis('bottom')
        self.plot.hideAxis('left')
        
        self._text_items = [] 
Example #3
Source File: OrthoImageItem.py    From rapidtide with Apache License 2.0 6 votes vote down vote up
def newColorbar(view, left, top, impixpervoxx, impixpervoxy, imgsize):
    cb_xdim = imgsize // 10
    cb_ydim = imgsize
    theviewbox = pg.ViewBox(enableMouse=False)
    theviewbox.setRange(QtCore.QRectF(0, 0, cb_xdim, cb_ydim),
                        xRange=(0, cb_xdim - 1), yRange=(0, cb_ydim - 1), padding=0.0,
                        disableAutoRange=True)
    theviewbox.setAspectLocked()

    thecolorbarwin = pg.ImageItem()
    theviewbox.addItem(thecolorbarwin)
    thecolorbarwin.translate(left, top)
    thecolorbarwin.scale(impixpervoxx, impixpervoxy)

    colorbarvals = np.zeros((cb_xdim, cb_ydim), dtype=np.float64)
    for i in range(0, cb_ydim):
        colorbarvals[:, i] = i * (1.0 / (cb_ydim - 1.0))
    thecolorbarwin.setImage(colorbarvals, levels=[0.0, 1.0])
    return thecolorbarwin, theviewbox 
Example #4
Source File: visualization.py    From RoboND-DeepLearning-Project with MIT License 6 votes vote down vote up
def run(self):
        app = QtGui.QApplication([])
        ## Create window with GraphicsView widget
        win = pg.GraphicsLayoutWidget()
        win.show()  ## show widget alone in its own window
        win.setWindowTitle('pyqtgraph example: ImageItem')
        view = win.addViewBox()

        ## lock the aspect ratio so pixels are always square
        view.setAspectLocked(True)

        ## Create image item
        self.img = pg.ImageItem(border='w')
        view.addItem(self.img)

        ## Set initial view bounds
        view.setRange(QtCore.QRectF(0, 0, self.image_hw, self.image_hw))

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

        app.exec_() 
Example #5
Source File: batchviewer.py    From BatchViewer with Apache License 2.0 6 votes vote down vote up
def init(self, width, height):
        self.rect = QtCore.QRect(0, 0, width, height)
        self.imageItem = pg.ImageItem()
        self.imageItem.setImage(None)

        self.graphicsScene = pg.GraphicsScene()
        self.graphicsScene.addItem(self.imageItem)

        self.graphicsView = pg.GraphicsView()
        self.graphicsView.setRenderHint(QtGui.QPainter.Antialiasing)
        self.graphicsView.setScene(self.graphicsScene)

        layout = QtGui.QHBoxLayout()
        layout.addWidget(self.graphicsView)
        self.setLayout(layout)
        self.setMaximumSize(width, height)
        self.setMinimumSize(width-10, height-10) 
Example #6
Source File: visualization.py    From RoboND-DeepLearning-Project with MIT License 6 votes vote down vote up
def run(self):
        app = QtGui.QApplication([])
        ## Create window with GraphicsView widget
        win = pg.GraphicsLayoutWidget()
        win.show()  ## show widget alone in its own window
        win.setWindowTitle('pyqtgraph example: ImageItem')
        view = win.addViewBox()

        ## lock the aspect ratio so pixels are always square
        view.setAspectLocked(True)

        ## Create image item
        self.img = pg.ImageItem(border='w')
        view.addItem(self.img)

        ## Set initial view bounds
        view.setRange(QtCore.QRectF(0, 0, 2*self.image_hw, self.image_hw))

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

        app.exec_() 
Example #7
Source File: renderers.py    From binglide with MIT License 6 votes vote down vote up
def __init__(self, parent=None, *args, **kwargs):
        Renderer.__init__(self, *args, **kwargs)
        super().__init__(parent)
        self.ci.layout.setContentsMargins(0, 0, 0, 0)
        self.ci.layout.setSpacing(0)

        self.view = self.addViewBox()
        # self.view.setAspectLocked(True)
        self.view.setAspectLocked(lock=False)

        self.view.invertY(True)

        self.view.setContentsMargins(0, 0, 0, 0)

        self.img = pg.ImageItem(border='w')
        self.view.addItem(self.img)

        self.live_region = False

        if self.needs_region:
            self.setup_region()

        self.show() 
Example #8
Source File: masks.py    From suite2p with GNU General Public License v3.0 6 votes vote down vote up
def make_colorbar(parent, b0):
    colorbarW = pg.GraphicsLayoutWidget(parent)
    colorbarW.setMaximumHeight(60)
    colorbarW.setMaximumWidth(150)
    colorbarW.ci.layout.setRowStretchFactor(0, 2)
    colorbarW.ci.layout.setContentsMargins(0, 0, 0, 0)
    parent.l0.addWidget(colorbarW, b0, 0, 1, 2)
    parent.colorbar = pg.ImageItem()
    cbar = colorbarW.addViewBox(row=0, col=0, colspan=3)
    cbar.setMenuEnabled(False)
    cbar.addItem(parent.colorbar)
    parent.clabel = [
        colorbarW.addLabel("0.0", color=[255, 255, 255], row=1, col=0),
        colorbarW.addLabel("0.5", color=[255, 255, 255], row=1, col=1),
        colorbarW.addLabel("1.0", color=[255, 255, 255], row=1, col=2),
    ] 
Example #9
Source File: gccNMFInterface.py    From gcc-nmf with MIT License 5 votes vote down vote up
def initVisualizationWidgets(self):
        self.inputSpectrogramWidget = self.createGraphicsLayoutWidget(self.backgroundColor)
        inputSpectrogramViewBox = self.inputSpectrogramWidget.addViewBox()
        self.inputSpectrogramHistoryImageItem = pg.ImageItem(self.inputSpectrogramHistory.values)  # , border=self.borderColor)
        inputSpectrogramViewBox.addItem(self.inputSpectrogramHistoryImageItem)
        inputSpectrogramViewBox.setRange(xRange=(0, self.inputSpectrogramHistory.values.shape[1]), yRange=(0, self.inputSpectrogramHistory.values.shape[0]), padding=0)
        
        self.outputSpectrogramWidget = self.createGraphicsLayoutWidget(self.backgroundColor)
        outputSpectrogramViewBox = self.outputSpectrogramWidget.addViewBox()
        self.outputSpectrogramHistoryImageItem = pg.ImageItem(self.outputSpectrogramHistory.values)  # , border=self.borderColor)
        outputSpectrogramViewBox.addItem(self.outputSpectrogramHistoryImageItem)
        outputSpectrogramViewBox.setRange(xRange=(0, self.outputSpectrogramHistory.values.shape[1] - 1), yRange=(0, self.outputSpectrogramHistory.values.shape[0] - 1), padding=0)
        
        self.gccPHATHistoryWidget = self.createGraphicsLayoutWidget(self.backgroundColor)
        gccPHATHistoryViewBox = self.gccPHATHistoryWidget.addViewBox()  # invertY=True)
        self.gccPHATImageItem = pg.ImageItem(self.gccPHATHistory.values)  # , border=self.borderColor)
        gccPHATHistoryViewBox.addItem(self.gccPHATImageItem)
        gccPHATHistoryViewBox.setRange(xRange=(0, self.gccPHATHistory.values.shape[1] - 1), yRange=(0, self.gccPHATHistory.values.shape[0] - 1), padding=0)
        
        self.tdoaPlotDataItem = pg.PlotDataItem( pen=pg.mkPen((255, 0, 0, 255), width=4) )
        gccPHATHistoryViewBox.addItem(self.tdoaPlotDataItem)

        dictionarySize = self.dictionarySizes[self.dictionarySizeDropDown.currentIndex()]
        self.coefficientMaskWidget = self.createGraphicsLayoutWidget(self.backgroundColor)
        self.coefficientMaskViewBox = self.coefficientMaskWidget.addViewBox()
        self.coefficientMaskHistory = self.coefficientMaskHistories[dictionarySize]
        self.coefficientMaskHistoryImageItem = pg.ImageItem()  # , border=self.borderColor)
        self.coefficientMaskViewBox.addItem(self.coefficientMaskHistoryImageItem)
        
        self.dictionaryWidget = self.createGraphicsLayoutWidget(self.backgroundColor)
        self.dictionaryViewBox = self.dictionaryWidget.addViewBox()
        self.dictionaryImageItem = pg.ImageItem()  # 1 - visualizedDictionary)#, border=self.borderColor)
        self.dictionaryViewBox.addItem(self.dictionaryImageItem)
        self.dictionarySizeChanged(False) 
Example #10
Source File: OrthoImageItem.py    From rapidtide with Apache License 2.0 5 votes vote down vote up
def newViewWindow(view, xdim, ydim, left, top, impixpervoxx, impixpervoxy, imgsize, enableMouse=False):
    theviewbox = view.addViewBox(enableMouse=enableMouse, enableMenu=False, lockAspect=1.0)
    theviewbox.setAspectLocked()
    theviewbox.setRange(QtCore.QRectF(0, 0, imgsize, imgsize), padding=0., disableAutoRange=True)
    theviewbox.setBackgroundColor([50, 50, 50])

    theviewfgwin = pg.ImageItem()
    theviewbox.addItem(theviewfgwin)
    theviewfgwin.setZValue(10)
    theviewfgwin.translate(left, top)
    theviewfgwin.scale(impixpervoxx, impixpervoxy)

    theviewbgwin = pg.ImageItem()
    theviewbox.addItem(theviewbgwin)
    theviewbgwin.setZValue(0)
    theviewbgwin.translate(left, top)
    theviewbgwin.scale(impixpervoxx, impixpervoxy)

    theviewvLine = pg.InfiniteLine(angle=90, movable=False, pen='g')
    theviewvLine.setZValue(20)
    theviewbox.addItem(theviewvLine)
    theviewhLine = pg.InfiniteLine(angle=0, movable=False, pen='g')
    theviewhLine.setZValue(20)
    theviewbox.addItem(theviewhLine)

    return theviewfgwin, theviewbgwin, theviewvLine, theviewhLine, theviewbox 
Example #11
Source File: plotly_test.py    From VNect-tensorflow with Apache License 2.0 5 votes vote down vote up
def __init__(self, parent=None):
        super(App, self).__init__(parent)

        #### Create Gui Elements ###########
        self.mainbox = QtGui.QWidget()
        self.setCentralWidget(self.mainbox)
        self.mainbox.setLayout(QtGui.QVBoxLayout())

        self.canvas = pg.GraphicsLayoutWidget()
        self.mainbox.layout().addWidget(self.canvas)

        self.label = QtGui.QLabel()
        self.mainbox.layout().addWidget(self.label)

        self.view = self.canvas.addViewBox()
        self.view.setAspectLocked(True)
        self.view.setRange(QtCore.QRectF(0,0, 100, 100))

        #  image plot
        self.img = pg.ImageItem(border='w')
        self.view.addItem(self.img)

        self.canvas.nextRow()
        #  line plot
        self.otherplot = self.canvas.addPlot()
        self.h2 = self.otherplot.plot(pen='y')


        #### Set Data  #####################

        self.x = np.linspace(0,50., num=100)
        self.X,self.Y = np.meshgrid(self.x,self.x)

        self.counter = 0
        self.fps = 0.
        self.lastupdate = time.time()

        #### Start  #####################
        self._update() 
Example #12
Source File: gui.py    From webcam-pix2pix-tensorflow with MIT License 5 votes vote down vote up
def _add_image_to_layout(layout, row=None, col=None, rowspan=1, colspan=1, title=''):
    i = pg.ImageItem(border='w')
    i.setOpts(axisOrder='row-major')
    
    l = layout.addLayout()
    l.addLabel(title)
    l.nextRow()

    v = l.addViewBox(lockAspect=True, invertY=True, row=row, col=col, rowspan=rowspan, colspan=colspan)
    v.addItem(i)
    return {'img':i, 'view':v, 'layout':l} 
Example #13
Source File: display.py    From OpenNFB with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, name, **config):
        self.img = pg.ImageItem()
        self.plot_widget = pg.PlotWidget(title=name)
        self.plot_widget.block = self

        self.plot_widget.addItem(self.img)

        #self.img_array = np.zeros((1000, self.CHUNKSZ/2+1))
        self.img_array = np.zeros((1000, 48))

        # bipolar colormap
        pos = np.array([0., 1., 0.5, 0.25, 0.75])
        color = np.array([[0,255,255,255], [255,255,0,255], [0,0,0,255], (0, 0, 255, 255), (255, 0, 0, 255)], dtype=np.ubyte)
        cmap = pg.ColorMap(pos, color)
        lut = cmap.getLookupTable(0.0, 1.0, 256)

        self.img.setLookupTable(lut)
        self.img.setLevels([-2,7])

        FS = 48 * 2

        freq = np.arange((self.CHUNKSZ/2)+1)/(float(self.CHUNKSZ)/FS)
        yscale = 1.0/(self.img_array.shape[1]/freq[-1])
        self.img.scale((1./FS)*self.CHUNKSZ, yscale)

        self.plot_widget.setLabel('left', 'Frequency', units='Hz')

        self.win = np.hanning(self.CHUNKSZ)
        #self.show()
        super(Spectrograph, self).__init__(**config) 
Example #14
Source File: SpectrogramWidget.py    From OpenNFB with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, blockSize = 1024, samplingFreq = 250):
        super(SpectrogramWidget, self).__init__()

        self.blockSize = blockSize

        self.img = pg.ImageItem()
        self.addItem(self.img)

        self.img_array = np.zeros((100, (blockSize/2)+1))

        # bipolar colormap
        pos = np.array([0., 1., 0.5, 0.25, 0.75])
        color = np.array([[0,255,255,255], [255,255,0,255], [0,0,0,255], (0, 0, 255, 255), (255, 0, 0, 255)], dtype=np.ubyte)
        cmap = pg.ColorMap(pos, color)
        lut = cmap.getLookupTable(0.0, 1.0, 256)

        self.img.setLookupTable(lut)
        self.img.setLevels([-50,40])

        freq = np.arange((blockSize/2)+1)/(float(blockSize)/samplingFreq)
        yscale = 1.0/(self.img_array.shape[1]/freq[-1])
        self.img.scale((1./samplingFreq)*blockSize, yscale)

        self.setLabel('left', 'Frequency', units='Hz')

        self.win = np.hanning(blockSize)
        self.show()

        self.buffer = np.zeros(blockSize) 
Example #15
Source File: plotutils.py    From orange3-geo with GNU General Public License v3.0 5 votes vote down vote up
def _update_map_item(self):
        """Update ImageItem with current image."""
        self.map_item.setImage(np.array(self.map))
        self.map_item.setRect(self.ts_norm) 
Example #16
Source File: plotutils.py    From orange3-geo with GNU General Public License v3.0 5 votes vote down vote up
def __new_map_item(z):
        map_item = ImageItem(autoLevels=False)
        map_item.setOpts(axisOrder='row-major')
        map_item.setZValue(z)
        return map_item 
Example #17
Source File: fishplots.py    From stytra with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, acc, n_points=300):
        super().__init__()
        self.title = "Tail curvature"
        self.acc = acc
        self.headers = None
        self.n_points = n_points

        self.setLayout(QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.display_widget = pg.GraphicsLayoutWidget()
        self.vb_display = pg.ViewBox()
        self.display_widget.addItem(self.vb_display)
        self.image_item = pg.ImageItem()
        self.vb_display.addItem(self.image_item)

        self.image_item.setLevels((-0.6, 0.6))
        self.image_item.setLookupTable(
            pg.ColorMap(
                np.linspace(0, 1, 5),
                np.array(
                    [
                        [0.42107294, 0.80737975, 0.49219722],
                        [0.23166242, 0.39962101, 0.32100403],
                        [0.0, 0.0, 0.0],
                        [0.46170494, 0.30327584, 0.38740225],
                        [0.91677407, 0.58427975, 0.92293321],
                    ]
                ),
            ).getLookupTable(alpha=False)
        )
        self.layout().addWidget(self.display_widget) 
Example #18
Source File: plot.py    From qspectrumanalyzer with GNU General Public License v3.0 5 votes vote down vote up
def update_plot(self, data_storage):
        """Update waterfall plot"""
        self.counter += 1

        # Create waterfall image on first run
        if self.counter == 1:
            self.waterfallImg = pg.ImageItem()
            self.waterfallImg.scale((data_storage.x[-1] - data_storage.x[0]) / len(data_storage.x), 1)
            self.plot.clear()
            self.plot.addItem(self.waterfallImg)

        # Roll down one and replace leading edge with new data
        self.waterfallImg.setImage(data_storage.history.buffer[-self.counter:].T,
                                   autoLevels=False, autoRange=False)

        # Move waterfall image to always start at 0
        self.waterfallImg.setPos(
            data_storage.x[0],
            -self.counter if self.counter < self.history_size else -self.history_size
        )

        # Link histogram widget to waterfall image on first run
        # (must be done after first data is received or else levels would be wrong)
        if self.counter == 1 and self.histogram_layout:
            self.histogram.setImageItem(self.waterfallImg) 
Example #19
Source File: gui2p.py    From suite2p with GNU General Public License v3.0 4 votes vote down vote up
def make_graphics(self, b0):
        ##### -------- MAIN PLOTTING AREA ---------- ####################
        self.win = pg.GraphicsLayoutWidget()
        self.win.move(600, 0)
        self.win.resize(1000, 500)
        self.l0.addWidget(self.win, 1, 2, b0-1, 30)
        layout = self.win.ci.layout
        # --- cells image
        self.p1 = graphics.ViewBox(parent=self, lockAspect=True, name="plot1", border=[100, 100, 100], invertY=True)
        self.win.addItem(self.p1, 0, 0)
        self.p1.setMenuEnabled(False)
        self.p1.scene().contextMenuItem = self.p1
        self.view1 = pg.ImageItem(viewbox=self.p1, parent=self)
        self.view1.autoDownsample = False
        self.color1 = pg.ImageItem(viewbox=self.p1, parent=self)
        self.color1.autoDownsample = False
        self.p1.addItem(self.view1)
        self.p1.addItem(self.color1)
        self.view1.setLevels([0,255])
        self.color1.setLevels([0,255])
        #self.view1.setImage(np.random.rand(500,500,3))
        #x = np.arange(0,500)
        #img = np.concatenate((np.zeros((500,500,3)), 127*(1+np.tile(np.sin(x/100)[:,np.newaxis,np.newaxis],(1,500,1)))),axis=-1)
        #self.color1.setImage(img)
        # --- noncells image
        self.p2 = graphics.ViewBox(parent=self, lockAspect=True, name="plot2", border=[100, 100, 100], invertY=True)
        self.win.addItem(self.p2, 0, 1)
        self.p2.setMenuEnabled(False)
        self.p2.scene().contextMenuItem = self.p2
        self.view2 = pg.ImageItem(viewbox=self.p1, parent=self)
        self.view2.autoDownsample = False
        self.color2 = pg.ImageItem(viewbox=self.p1, parent=self)
        self.color2.autoDownsample = False
        self.p2.addItem(self.view2)
        self.p2.addItem(self.color2)
        self.view2.setLevels([0,255])
        self.color2.setLevels([0,255])

        # LINK TWO VIEWS!
        self.p2.setXLink("plot1")
        self.p2.setYLink("plot1")

        # --- fluorescence trace plot
        self.p3 = graphics.TraceBox(parent=self, invertY=False)
        self.p3.setMouseEnabled(x=True, y=False)
        self.p3.enableAutoRange(x=True, y=True)
        self.win.addItem(self.p3, row=1, col=0, colspan=2)
        #self.p3 = pg.PlotItem()
        #self.v3.addItem(self.p3)
        self.win.ci.layout.setRowStretchFactor(0, 2)
        layout = self.win.ci.layout
        layout.setColumnMinimumWidth(0, 1)
        layout.setColumnMinimumWidth(1, 1)
        layout.setHorizontalSpacing(20)
        #self.win.scene().sigMouseClicked.connect(self.plot_clicked) 
Example #20
Source File: display.py    From OpenNFB with GNU General Public License v3.0 4 votes vote down vote up
def init(self, name):
        self.name = name

        self.autoscale_button = QtGui.QCheckBox('Autoscale')
        self.autoscale_button.setCheckState(True)

        self.welch_button = QtGui.QCheckBox('Use Welch')
        self.welch_button.setCheckState(False)

        self.plot_widget = pg.PlotWidget(title=name)
        self.plot_widget.block = self

        self.plot_widget.setLabel('bottom', 'Frequency', units='Hz')
        self.plot_widget.setLabel("left", "Time", units='s')

        #TODO: listener for this
        #self.plot_widget.setYRange(-self.history_size / self.sampling_rate, 0)

        #self.plot_widget.setLimits(xMin=0, yMax=0)
        #self.plot_widget.showButtons()
        #self.waterfallPlotWidget.setAspectLocked(True)
        #self.waterfallPlotWidget.setDownsampling(mode="peak")
        #self.waterfallPlotWidget.setClipToView(True)
        
        # Setup histogram widget (for controlling waterfall plot levels and gradients)
        self.histogram = pg.PlotWidget(title='Histogram')
        self.waterfallHistogram = pg.HistogramLUTItem()
        self.histogram.addItem(self.waterfallHistogram)
        self.waterfallHistogram.gradient.loadPreset("flame")
        #self.waterfallHistogram.setHistogramRange(-50, 0)
        #self.waterfallHistogram.setLevels(-50, 0)

        self.waterfallImg = pg.ImageItem()
        self.plot_widget.clear()
        self.plot_widget.addItem(self.waterfallImg)      
        self.waterfallHistogram.setImageItem(self.waterfallImg)

        self.setup_range()

        self.update_counter = 0 
Example #21
Source File: usrp_demo.py    From pysdr with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self):
        super().__init__()
        
        # Set up layout
        grid = QGridLayout()
        self.setLayout(grid)
        
        pg.setConfigOptions(antialias=False) # True seems to work as well

        # Create pushbutton that resets the views
        self.button = QPushButton('Reset All Zooms', self)
        self.button.clicked.connect(self.handleButton)
        grid.addWidget(self.button, 0, 0)
        
        
        # create time plot
        self.time_plot = pg.PlotWidget(labels={'left': 'Amplitude', 'bottom': 'Time [microseconds]'}, enableMenu=False)
        self.time_plot.getPlotItem().getViewBox().setMouseMode(pg.ViewBox.RectMode)
        self.time_plot.setMouseEnabled(x=False, y=True)
        self.time_plot_curve_i = self.time_plot.plot([]) 
        self.time_plot_curve_q = self.time_plot.plot([]) 
        grid.addWidget(self.time_plot, 1, 0)
        
        # create fft plot
        self.fft_plot = pg.PlotWidget(labels={'left': 'PSD', 'bottom': 'Frequency [MHz]'}, enableMenu=False)
        self.fft_plot.getPlotItem().getViewBox().setMouseMode(pg.ViewBox.RectMode)
        self.fft_plot.setMouseEnabled(x=False, y=True)
        self.fft_plot_curve_fft = self.fft_plot.plot([]) 
        grid.addWidget(self.fft_plot, 2, 0)
        
        # Create waterfall plot
        self.waterfall = pg.PlotWidget(labels={'left': 'Time [s]', 'bottom': 'Frequency [MHz]'}, enableMenu=False)
        self.waterfall.getPlotItem().getViewBox().translateBy(x=10.0)
        self.imageitem = pg.ImageItem()
        self.waterfall.addItem(self.imageitem)
        self.waterfall.setMouseEnabled(x=False, y=False)
        grid.addWidget(self.waterfall, 3, 0)
  
        self.setGeometry(300, 300, 300, 220) # window placement and size
        self.setWindowTitle('RTL-SDR Demo')
    
        self.show() # not blocking 
Example #22
Source File: monitor_control.py    From stytra with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, *args, display_size=(1280, 800), display, **kwargs):
        super().__init__(*args, **kwargs)

        self.display = display

        self.view_box = pg.ViewBox(invertY=True, lockAspect=1, enableMouse=False)
        self.addItem(self.view_box)

        self.roi_box = pg.ROI(
            maxBounds=QRectF(0, 0, display_size[0], display_size[1]),
            size=display.size,
            pos=display.pos,
        )

        self.roi_box.addScaleHandle([0, 0], [1, 1])
        self.roi_box.addScaleHandle([1, 1], [0, 0])
        self.roi_box.sigRegionChanged.connect(self.set_param_val)
        self.display.sig_param_changed.connect(self.set_roi)
        self.view_box.addItem(self.roi_box)
        self.view_box.setRange(
            QRectF(0, 0, display_size[0], display_size[1]),
            update=True,
            disableAutoRange=True,
        )
        self.view_box.addItem(
            pg.ROI(
                pos=(1, 1),
                size=(display_size[0] - 1, display_size[1] - 1),
                movable=False,
                pen=(80, 80, 80),
            )
        )

        self.calibration_points = pg.ScatterPlotItem(pen=(255, 0, 0), brush=None)
        self.calibration_frame = pg.PlotCurveItem(
            brush=(120, 10, 10), pen=(200, 10, 10), fill_level=1
        )

        self.camera_image = pg.ImageItem()

        self.view_box.addItem(self.calibration_frame)
        self.view_box.addItem(self.camera_image)
        self.view_box.addItem(self.calibration_points)

        self.setting_param_val = False

        self.set_param_val() 
Example #23
Source File: multiplot.py    From kite with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, sandbox, component, title='Untitled'):
        pg.PlotItem.__init__(self)
        self.title = title
        self.sandbox = sandbox
        self.component = component

        self.cursor = CursorRect()
        self.addCursor()

        self.setAspectLocked(True)
        self.setLabels(
            bottom=('Easting', 'm'),
            left=('Northing', 'm'))

        border_pen = pg.mkPen(255, 255, 255, 50)

        self.image = pg.ImageItem(
            None,
            autoDownsample=False,
            border_pen=border_pen,
            useOpenGL=True)
        self.addItem(self.image)

        self.title_label = pg.LabelItem(
            text='<span style="color: #9E9E9E;">'
                 '%s</span>' % self.title,
            justify='right', size='10pt',
            parent=self)
        self.title_label.anchor(
            itemPos=(0., 0.),
            parentPos=(.01, .01))
        self.title_label.setOpacity(.6)

        self.hint_text = None

        self.sandbox.sigModelUpdated.connect(
            self.update)
        self.sandbox.sources.modelAboutToBeReset.connect(
            self.removeSourceROIS)
        self.sandbox.sources.modelReset.connect(
            self.addSourceROIS)

        self.update()
        self.rois = []
        self.addSourceROIS()