Python pyqtgraph.GraphicsLayoutWidget() Examples

The following are 30 code examples of pyqtgraph.GraphicsLayoutWidget(). 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: play.py    From simulator with GNU General Public License v3.0 7 votes vote down vote up
def plot_team(self):
        # these would contain list of x coordinates
        self.Monitors_rounds = []
        self.WIPs_rounds = []
        self.MPs_rounds = []
        # these would contain list of yc coordinates
        self.Monitors_qty = []
        self.WIPs_qty = []
        self.MPs_qty = []
        self.win = pg.GraphicsLayoutWidget()
        self.win.setWindowTitle("Number of Peers in the Team")
        self.win.resize(800, 600)

        # Enable antialiasing for prettier plots
        # pg.setConfigOptions(antialias=True)
        self.p3 = self.win.addPlot()    # Adding plot to window like matplotlib subplot method
        self.p3.addLegend()
        # Create separate plots to handle regular,monitor and malicious peer it is much like matplotlib plot method
        self.lineWIPs = self.p3.plot(pen=(None), symbolBrush=(0, 0, 255), symbolPen='b', name='#WIP')
        self.lineMonitors = self.p3.plot(pen=(None), symbolBrush=(0, 255, 0), symbolPen='g', name='#Monitors Peers')
        self.lineMPs = self.p3.plot(pen=(None), symbolBrush=(255, 0, 0), symbolPen='r', name='Malicious Peers')

        total_peers = self.number_of_monitors + self.number_of_peers + self.number_of_malicious
        self.p3.setRange(xRange=[0, self.number_of_rounds], yRange=[0, total_peers])
        self.win.show() 
Example #2
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 #3
Source File: analysis.py    From pyFlightAnalysis with MIT License 6 votes vote down vote up
def draw_predefined_graph(self, name):
        
        def add_context_action(ax):
            def callback(*args, **kargs):
                for item in ax.items():
                    if isinstance(item, pg.PlotDataItem):
                        if item.opts['symbol'] is None:
                            item.setData(item.xData, item.yData, symbol='s')
                        else:
                            item.setData(item.xData, item.yData, symbol=None) 
            return callback
        
        if name == 'XY_Estimation':
            graph_xy =  pg.GraphicsLayoutWidget()
            self.default_tab.addTab(graph_xy, name)
            ax = graph_xy.addPlot(row=0, col=0)
            show_marker_action = QtGui.QAction('show/hide marker', graph_xy)
            show_marker_action.triggered.connect(add_context_action(ax))
            data_index = list(list(self.data_dict.keys())).index('vehicle_local_position')
            x = self.log_data_list[data_index].data['x']
            y = self.log_data_list[data_index].data['y']
            # plot the xy trace line in red
            ax.plot(x, y, pen=(255, 0, 0)) 
Example #4
Source File: analysis.py    From pyFlightAnalysis with MIT License 6 votes vote down vote up
def callback_graph_index_combobox_changed(self, index):
        """Add clicked config graph to Data plotting area"""
        print(index)
#         if index == self.graph_number:
#             # choose new
#             self.graph_number += 1
#             # add a graph
#             graph_widget = pg.GraphicsLayoutWidget()
#             graph_widget.addPlot(row=0, col=0)
#             self.graph_lines_dict.setdefault(graph_widget, 0)
#             for data in self.data_plotting:
#                 data[1].clear()
#                 for i in range(1, self.graph_number + 1):
#                     data[1].addItem(str(i))
#                 data[1].addItem('New')
#         else:
#             # change current curve's graph
#             pass 
Example #5
Source File: analysis.py    From pyFlightAnalysis with MIT License 6 votes vote down vote up
def callback_analysis_graph_data_checked(self, curve_name_with_data):
        color_list = [(255, 0, 0), 
                      (0, 255, 0), 
                      (0, 0, 255),
                      (0, 255, 255),
                      (255, 0, 255), 
                      (155, 0, 160),
                      (0, 155, 155)]
        curve_name, data = curve_name_with_data
        data_type = data[0]
        if curve_name not in self.analysis_graph_list:
            new_graph = pg.GraphicsLayoutWidget()
            ax = new_graph.addPlot(row=0, col=0) 
            ax.addLegend()
            self.analysis_graph_list[curve_name] = new_graph
            self.default_tab.addTab(new_graph, curve_name)
            self.default_tab.setCurrentWidget(new_graph)
            for ind, curve_data in enumerate(data[1:]):
                ax.plot(curve_data[0], curve_data[1], pen=color_list[ind%len(color_list)], name=curve_data[2]) 
Example #6
Source File: crosscorrelogramviewer.py    From tridesclous with MIT License 6 votes vote down vote up
def __init__(self, controller=None, parent=None):
        WidgetBase.__init__(self, parent=parent, controller=controller)
        
        self.layout = QT.QVBoxLayout()
        self.setLayout(self.layout)
        
        h = QT.QHBoxLayout()
        self.layout.addLayout(h)

        but = QT.QPushButton('settings')
        but.clicked.connect(self.open_settings)
        h.addWidget(but)

        but = QT.QPushButton('compute')
        but.clicked.connect(self.compute_ccg)
        h.addWidget(but)
        
        self.grid = pg.GraphicsLayoutWidget()
        self.layout.addWidget(self.grid)
        
        self.ccg = None 
Example #7
Source File: plot.py    From qspectrumanalyzer with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, layout):
        if not isinstance(layout, pg.GraphicsLayoutWidget):
            raise ValueError("layout must be instance of pyqtgraph.GraphicsLayoutWidget")

        self.layout = layout

        self.main_curve = True
        self.main_color = pg.mkColor("y")
        self.persistence = False
        self.persistence_length = 5
        self.persistence_decay = "exponential"
        self.persistence_color = pg.mkColor("g")
        self.persistence_data = None
        self.persistence_curves = None
        self.peak_hold_max = False
        self.peak_hold_max_color = pg.mkColor("r")
        self.peak_hold_min = False
        self.peak_hold_min_color = pg.mkColor("b")
        self.average = False
        self.average_color = pg.mkColor("c")
        self.baseline = False
        self.baseline_color = pg.mkColor("m")

        self.create_plot() 
Example #8
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 #9
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 #10
Source File: label_events.py    From ConvNetQuake with MIT License 5 votes vote down vote up
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) 
Example #11
Source File: gccNMFInterface.py    From gcc-nmf with MIT License 5 votes vote down vote up
def createGraphicsLayoutWidget(self, backgroundColor, border=None, contentMargins=(0, 0, 0, 0)):
        graphicsLayoutWidget = pg.GraphicsLayoutWidget(border=border)
        graphicsLayoutWidget.setBackground(backgroundColor)
        graphicsLayoutWidget.ci.layout.setContentsMargins(*contentMargins)
        graphicsLayoutWidget.ci.layout.setSpacing(0)
        return graphicsLayoutWidget 
Example #12
Source File: publish_performance.py    From lbry-sdk with MIT License 5 votes vote down vote up
def generate_publishes(self):

        win = pg.GraphicsLayoutWidget(show=True)
        win.setWindowTitle('orchstr8: performance monitor')
        win.resize(1800, 600)

        p4 = win.addPlot()
        p4.addLegend()
        p4.setDownsampling(mode='peak')
        p4.setClipToView(True)
        self.profiler.graph = p4

        for block in range(self.blocks):
            for txn in range(self.txns_per_block):
                name = f'block{block}txn{txn}'
                self.profiler.start('total')
                yield self.service.lbry.daemon.jsonrpc_publish(
                    name=name, bid=self.random.randrange(1, 5)/1000.0,
                    file_path=self.publish_file, metadata={
                        "description": "Some interesting content",
                        "title": "My interesting content",
                        "author": "Video shot by me@example.com",
                        "language": "en", "license": "LBRY Inc", "nsfw": False
                    }
                )
                self.profiler.stop('total')
                self.profiler.draw()

            yield self.service.lbrycrd.generate(1) 
Example #13
Source File: lineplot1d.py    From argos with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, collector, parent=None):
        """ Constructor. See AbstractInspector constructor for parameters.
        """
        super(PgLinePlot1d, self).__init__(collector, parent=parent)

        # The sliced array is kept in memory. This may be different per inspector, e.g. 3D
        # inspectors may decide that this uses to much memory. The slice is therefor not stored
        # in the collector.
        self.slicedArray = None

        self.graphicsLayoutWidget = pg.GraphicsLayoutWidget()
        self.contentsLayout.addWidget(self.graphicsLayoutWidget)
        self.titleLabel = self.graphicsLayoutWidget.addLabel('<plot title goes here>', 0, 0)

        self.plotItem = ArgosPgPlotItem()
        self.viewBox = self.plotItem.getViewBox()
        self.graphicsLayoutWidget.addItem(self.plotItem, 1, 0)

        # Probe
        probePen = pg.mkPen("#BFBFBF")
        probeShadowPen = pg.mkPen("#00000064", width=3)
        self.crossLineVerShadow = pg.InfiniteLine(angle=90, movable=False, pen=probeShadowPen)
        self.crossLineVertical = pg.InfiniteLine(angle=90, movable=False, pen=probePen)
        self.probeDataItem = pg.PlotDataItem(symbolPen=probePen)
        self.probeLabel = self.graphicsLayoutWidget.addLabel('', 2, 0, justify='left')

        # Configuration tree
        self._config = PgLinePlot1dCti(pgLinePlot1d=self, nodeName='1D line plot')

        # Connect signals
        # Based mouseMoved on crosshair.py from the PyQtGraph examples directory.
        # I did not use the SignalProxy because I did not see any difference.
        self.plotItem.scene().sigMouseMoved.connect(self.mouseMoved) 
Example #14
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 #15
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 #16
Source File: relativity.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes vote down vote up
def setupGUI(self):
        self.layout = QtGui.QVBoxLayout()
        self.layout.setContentsMargins(0,0,0,0)
        self.setLayout(self.layout)
        self.splitter = QtGui.QSplitter()
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.layout.addWidget(self.splitter)
        
        self.tree = ParameterTree(showHeader=False)
        self.splitter.addWidget(self.tree)
        
        self.splitter2 = QtGui.QSplitter()
        self.splitter2.setOrientation(QtCore.Qt.Vertical)
        self.splitter.addWidget(self.splitter2)
        
        self.worldlinePlots = pg.GraphicsLayoutWidget()
        self.splitter2.addWidget(self.worldlinePlots)
        
        self.animationPlots = pg.GraphicsLayoutWidget()
        self.splitter2.addWidget(self.animationPlots)
        
        self.splitter2.setSizes([int(self.height()*0.8), int(self.height()*0.2)])
        
        self.inertWorldlinePlot = self.worldlinePlots.addPlot()
        self.refWorldlinePlot = self.worldlinePlots.addPlot()
        
        self.inertAnimationPlot = self.animationPlots.addPlot()
        self.inertAnimationPlot.setAspectLocked(1)
        self.refAnimationPlot = self.animationPlots.addPlot()
        self.refAnimationPlot.setAspectLocked(1)
        
        self.inertAnimationPlot.setXLink(self.inertWorldlinePlot)
        self.refAnimationPlot.setXLink(self.refWorldlinePlot) 
Example #17
Source File: relativity.py    From tf-pose with Apache License 2.0 5 votes vote down vote up
def setupGUI(self):
        self.layout = QtGui.QVBoxLayout()
        self.layout.setContentsMargins(0,0,0,0)
        self.setLayout(self.layout)
        self.splitter = QtGui.QSplitter()
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.layout.addWidget(self.splitter)
        
        self.tree = ParameterTree(showHeader=False)
        self.splitter.addWidget(self.tree)
        
        self.splitter2 = QtGui.QSplitter()
        self.splitter2.setOrientation(QtCore.Qt.Vertical)
        self.splitter.addWidget(self.splitter2)
        
        self.worldlinePlots = pg.GraphicsLayoutWidget()
        self.splitter2.addWidget(self.worldlinePlots)
        
        self.animationPlots = pg.GraphicsLayoutWidget()
        self.splitter2.addWidget(self.animationPlots)
        
        self.splitter2.setSizes([int(self.height()*0.8), int(self.height()*0.2)])
        
        self.inertWorldlinePlot = self.worldlinePlots.addPlot()
        self.refWorldlinePlot = self.worldlinePlots.addPlot()
        
        self.inertAnimationPlot = self.animationPlots.addPlot()
        self.inertAnimationPlot.setAspectLocked(1)
        self.refAnimationPlot = self.animationPlots.addPlot()
        self.refAnimationPlot.setAspectLocked(1)
        
        self.inertAnimationPlot.setXLink(self.inertWorldlinePlot)
        self.refAnimationPlot.setXLink(self.refWorldlinePlot) 
Example #18
Source File: plot.py    From qspectrumanalyzer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, layout, histogram_layout=None):
        if not isinstance(layout, pg.GraphicsLayoutWidget):
            raise ValueError("layout must be instance of pyqtgraph.GraphicsLayoutWidget")

        if histogram_layout and not isinstance(histogram_layout, pg.GraphicsLayoutWidget):
            raise ValueError("histogram_layout must be instance of pyqtgraph.GraphicsLayoutWidget")

        self.layout = layout
        self.histogram_layout = histogram_layout

        self.history_size = 100
        self.counter = 0

        self.create_plot() 
Example #19
Source File: play.py    From simulator with GNU General Public License v3.0 5 votes vote down vote up
def plot_clr(self):
        self.clrs_per_round = []
        self.clr_win = pg.GraphicsLayoutWidget()
        self.clr_win.setWindowTitle('Chunk Loss Ratio')
        self.clr_win.resize(800, 700)
        self.clr_figure = self.clr_win.addPlot()
        self.clr_figure.addLegend()
        self.lineCLR = self.clr_figure.plot(pen=(None), symbolBrush=mkColor(
            '#000000'), name="CLR", symbol='o', clear=True)
        self.clr_figure.setRange(xRange=[0, self.number_of_rounds], yRange=[0, 1])
        self.clrData = [[], []]  # 2D list to store both the x and y coordinates
        self.clr_win.show() 
Example #20
Source File: play.py    From simulator with GNU General Public License v3.0 5 votes vote down vote up
def draw_buffer(self):
        self.buff_win = pg.GraphicsLayoutWidget()
        self.buff_win.setWindowTitle('Buffer Status')
        self.buff_win.resize(800, 700)

        self.total_peers = self.number_of_monitors + self.number_of_peers + self.number_of_malicious
        self.p4 = self.buff_win.addPlot()
        self.p4.showGrid(x=True, y=True, alpha=100)   # To show grid lines across x axis and y axis
        leftaxis = self.p4.getAxis('left')  # get left axis i.e y axis
        leftaxis.setTickSpacing(5, 1)    # to set ticks at a interval of 5 and grid lines at 1 space

        # Get different colors using matplotlib library
        if self.total_peers < 8:
            colors = cm.Set2(np.linspace(0, 1, 8))
        elif self.total_peers < 12:
            colors = cm.Set3(np.linspace(0, 1, 12))
        else:
            colors = cm.rainbow(np.linspace(0, 1, self.total_peers+1))
        self.QColors = [pg.hsvColor(color[0], color[1], color[2], color[3])
                        for color in colors]   # Create QtColors, each color would represent a peer

        self.Data = []  # To represent buffer out  i.e outgoing data from buffer
        self.OutData = []   # To represent buffer in i.e incoming data in buffer

        # a single line would reperesent a single color or peer, hence we would not need to pass a list of brushes
        self.lineIN = [None]*self.total_peers
        for ix in range(self.total_peers):
            self.lineIN[ix] = self.p4.plot(pen=(None), symbolBrush=self.QColors[ix], name='IN', symbol='o', clear=False)
            self.Data.append(set())
            self.OutData.append(set())

        # similiarly one line per peer to represent outgoinf data from buffer
        self.lineOUT = self.p4.plot(pen=(None), symbolBrush=mkColor('#CCCCCC'), name='OUT', symbol='o', clear=False)
        self.p4.setRange(xRange=[0, self.total_peers], yRange=[0, self.get_buffer_size()])
        self.buff_win.show()    # To actually show create window

        self.buffer_order = {}
        self.buffer_index = 0
        self.buffer_labels = []
        self.lastUpdate = pg.ptime.time()
        self.avgFps = 0.0 
Example #21
Source File: multiplot.py    From kite with GNU General Public License v3.0 5 votes vote down vote up
def resizeEvent(self, ev):
        pg.GraphicsLayoutWidget.resizeEvent(self, ev)
        if hasattr(self, 'plots'):
            viewbox = self.plots[0].getViewBox()
            viewbox.autoRange() 
Example #22
Source File: multiplot.py    From kite with GNU General Public License v3.0 5 votes vote down vote up
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)
            ]

        for plt in self.plots:
            plt.vb.menu = QtWidgets.QMenu(self)

        self.updateViews()
        getConfig().qconfig.updated.connect(self.updateViews)

        self._mov_sig = pg.SignalProxy(
            self.scene().sigMouseMoved,
            rateLimit=60, slot=self.mouseMoved) 
Example #23
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 #24
Source File: timeserieswidget.py    From dunya-desktop with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        pg.GraphicsLayoutWidget.__init__(self, parent)

        # Set 0 margin 0 spacing to cover the whole area.
        self.centralWidget.setContentsMargins(0, 0, 0, 0)
        self.centralWidget.setSpacing(0)

        self.limit = 600  # maximum number of samples to be plotted
        self.rois = []

        # flags
        self.is_pitch_plotted = False
        self.is_notes_added = False 
Example #25
Source File: waveformwidget.py    From dunya-desktop with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        pg.GraphicsLayoutWidget.__init__(self, parent=None)

        # Set 0 margin 0 spacing to cover the whole area.
        self.centralWidget.setContentsMargins(0, 0, 0, 0)
        self.centralWidget.setSpacing(0)

        self.section_items = [] 
Example #26
Source File: fishplots.py    From stytra with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, acc: QueueDataAccumulator, i_fish=0, n_bouts=10, n_save_max=300):
        super().__init__()
        self.title = "Bout shape"
        self.acc = acc
        self.bouts = deque()
        self.i_fish = i_fish
        self.processed_index = 0
        self.detection_params = Parametrized(
            params=dict(
                threshold=Param(0.2, (0.01, 5.0)),
                n_without_crossing=Param(5, (0, 10)),
                pad_before=Param(5, (0, 20)),
                pad_after=Param(5, (0, 20)),
                min_bout_len=Param(1, (1, 30)),
            )
        )
        self.n_bouts = n_bouts
        self.old_coords = None
        self.i_curve = 0
        self.n_save_max = n_save_max

        self.setLayout(QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.btn_editparam = QPushButton("Detection parameters")
        self.btn_editparam.clicked.connect(self.edit_params)
        self.layout().addWidget(self.btn_editparam)
        self.wnd_params = None

        self.vmax = 0
        self.lbl_vmax = QLabel()
        self.layout().addWidget(self.lbl_vmax)

        self.display_widget = pg.GraphicsLayoutWidget()
        self.layout().addWidget(self.display_widget)
        self.vb_display = pg.ViewBox()
        self.vb_display.setAspectLocked(True, 1)
        self.vb_display.setRange(xRange=[-1, 5], disableAutoRange=True)
        self.vb_display.invertY(True)
        self.display_widget.addItem(self.vb_display)

        self.bout_curves = [
            pg.PlotCurveItem(connect="finite") for _ in range(self.n_bouts)
        ]

        self.colors = np.zeros(self.n_bouts)
        self.decay_constant = 0.99

        self.bout_coords = None
        self.bout_state = BoutState(0, 0.0, 0, 0, 0)

        for c in self.bout_curves:
            self.vb_display.addItem(c) 
Example #27
Source File: mainWindow_ui.py    From RTGraph with MIT License 4 votes vote down vote up
def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(704, 558)
        MainWindow.setMinimumSize(QtCore.QSize(0, 0))
        MainWindow.setStyleSheet("")
        MainWindow.setTabShape(QtWidgets.QTabWidget.Rounded)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.Layout_controls = QtWidgets.QGridLayout()
        self.Layout_controls.setObjectName("Layout_controls")
        self.cBox_Speed = QtWidgets.QComboBox(self.centralwidget)
        self.cBox_Speed.setEditable(True)
        self.cBox_Speed.setObjectName("cBox_Speed")
        self.Layout_controls.addWidget(self.cBox_Speed, 1, 1, 1, 1)
        self.pButton_Stop = QtWidgets.QPushButton(self.centralwidget)
        self.pButton_Stop.setObjectName("pButton_Stop")
        self.Layout_controls.addWidget(self.pButton_Stop, 1, 3, 1, 1)
        self.cBox_Port = QtWidgets.QComboBox(self.centralwidget)
        self.cBox_Port.setEditable(True)
        self.cBox_Port.setObjectName("cBox_Port")
        self.Layout_controls.addWidget(self.cBox_Port, 0, 1, 1, 1)
        self.cBox_Source = QtWidgets.QComboBox(self.centralwidget)
        self.cBox_Source.setObjectName("cBox_Source")
        self.Layout_controls.addWidget(self.cBox_Source, 0, 0, 1, 1)
        self.pButton_Start = QtWidgets.QPushButton(self.centralwidget)
        self.pButton_Start.setMinimumSize(QtCore.QSize(0, 0))
        self.pButton_Start.setObjectName("pButton_Start")
        self.Layout_controls.addWidget(self.pButton_Start, 0, 3, 1, 1)
        self.sBox_Samples = QtWidgets.QSpinBox(self.centralwidget)
        self.sBox_Samples.setMinimum(1)
        self.sBox_Samples.setMaximum(100000)
        self.sBox_Samples.setProperty("value", 500)
        self.sBox_Samples.setObjectName("sBox_Samples")
        self.Layout_controls.addWidget(self.sBox_Samples, 0, 2, 1, 1)
        self.chBox_export = QtWidgets.QCheckBox(self.centralwidget)
        self.chBox_export.setEnabled(True)
        self.chBox_export.setObjectName("chBox_export")
        self.Layout_controls.addWidget(self.chBox_export, 1, 2, 1, 1)
        self.gridLayout.addLayout(self.Layout_controls, 7, 0, 1, 2)
        self.Layout_graphs = QtWidgets.QGridLayout()
        self.Layout_graphs.setObjectName("Layout_graphs")
        self.plt = GraphicsLayoutWidget(self.centralwidget)
        self.plt.setAutoFillBackground(False)
        self.plt.setStyleSheet("border: 0px;")
        self.plt.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.plt.setFrameShadow(QtWidgets.QFrame.Plain)
        self.plt.setLineWidth(0)
        self.plt.setObjectName("plt")
        self.Layout_graphs.addWidget(self.plt, 0, 0, 1, 1)
        self.gridLayout.addLayout(self.Layout_graphs, 2, 1, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow) 
Example #28
Source File: merge.py    From suite2p with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, parent=None):
        super(MergeWindow, self).__init__(parent)
        self.setGeometry(700,300,700,700)
        self.setWindowTitle('Choose merge options')
        self.cwidget = QtGui.QWidget(self)
        self.layout = QtGui.QGridLayout()
        self.layout.setVerticalSpacing(2)
        self.layout.setHorizontalSpacing(25)
        self.cwidget.setLayout(self.layout)
        self.win = pg.GraphicsLayoutWidget()
        self.layout.addWidget(self.win, 11, 0, 4, 4)
        self.p0 = self.win.addPlot(row=0, col=0)
        self.p0.setMouseEnabled(x=False,y=False)
        self.p0.enableAutoRange(x=True,y=True)
        # initial ops values
        mkeys = ['corr_thres', 'dist_thres']
        mlabels = ['correlation threshold', 'euclidean distance threshold']
        self.ops = {'corr_thres': 0.8, 'dist_thres': 100.0}
        self.layout.addWidget(QtGui.QLabel('Press enter in a text box to update params'), 0, 0, 1,2)
        self.layout.addWidget(QtGui.QLabel('(Correlations use "activity mode" and "bin" from main GUI)'), 1, 0, 1,2)
        self.layout.addWidget(QtGui.QLabel('>>>>>>>>>>>> Parameters <<<<<<<<<<<'), 2, 0, 1,2)
        self.doMerge = QtGui.QPushButton('merge selected ROIs', default=False, autoDefault=False)
        self.doMerge.clicked.connect(lambda: self.do_merge(parent))
        self.doMerge.setEnabled(False)
        self.layout.addWidget(self.doMerge, 9,0,1,1)

        self.suggestMerge = QtGui.QPushButton('next merge suggestion', default=False, autoDefault=False)
        self.suggestMerge.clicked.connect(lambda: self.suggest_merge(parent))
        self.suggestMerge.setEnabled(False)
        self.layout.addWidget(self.suggestMerge, 10,0,1,1)

        self.nMerge = QtGui.QLabel('= X possible merges found with these parameters')
        self.layout.addWidget(self.nMerge, 7,0,1,2)

        self.iMerge = QtGui.QLabel('suggested ROIs to merge: ')
        self.layout.addWidget(self.iMerge, 8,0,1,2)

        self.editlist = []
        self.keylist = []
        k=1
        for lkey,llabel in zip(mkeys, mlabels):
            qlabel = QtGui.QLabel(llabel)
            qlabel.setFont(QtGui.QFont("Times",weight=QtGui.QFont.Bold))
            self.layout.addWidget(qlabel, k*2+1,0,1,2)
            qedit = LineEdit(lkey,self)
            qedit.set_text(self.ops)
            qedit.setFixedWidth(90)
            qedit.returnPressed.connect(lambda: self.compute_merge_list(parent))
            self.layout.addWidget(qedit, k*2+2,0,1,2)
            self.editlist.append(qedit)
            self.keylist.append(lkey)
            k+=1

        print('creating merge window... this may take some time')
        self.CC  = np.matmul(parent.Fbin[parent.iscell], parent.Fbin[parent.iscell].T) / parent.Fbin.shape[-1]
        self.CC /= np.matmul(parent.Fstd[parent.iscell][:,np.newaxis],
                             parent.Fstd[parent.iscell][np.newaxis,:]) + 1e-3
        self.CC -= np.diag(np.diag(self.CC))

        self.compute_merge_list(parent) 
Example #29
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 #30
Source File: multiplot.py    From kite with GNU General Public License v3.0 4 votes vote down vote up
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)