Exemple #1
0
 def plot_selection(self):
     self.c.clear()
     for a in self.plots:
         a.clear()
     self.plots = []
     self.legendbox.scene().removeItem(self.legendbox)
     self.legendbox = pg.LegendItem((100, 60), offset=(70, 10))
     self.legendbox.setParentItem(self.graph.graphicsItem())
     num = 0
     cols = [(255, 0, 0), (255, 255, 0), (255, 0, 255), (255, 255, 255),
             (0, 255, 0), (0, 0, 255), (0, 255, 255), (255, 100, 100),
             (100, 255, 100), (100, 100, 255)]
     for a in self.thumbs.selectedItems():
         if len(cols):
             col = cols.pop()
         else:
             r = random.random() * 155 + 100
             g = random.random() * 155 + 100
             b = random.random() * 155 + 100
             col = (r, g, b, 255)
         c = self.graph.plot()
         c.setPen(col, width=2)
         ar = np.loadtxt(a.text() + '.txt')
         x = np.concatenate(ar[:, 0:1])
         y = np.concatenate(ar[:, 1:2])
         c.setData(x, y)
         self.legendbox.addItem(c, a.text().split('_')[-1])
         num += 1
         if num > 10:
             self.legendbox = pg.LegendItem((100, 60), offset=(70, 10))
             self.legendbox.setParentItem(self.graph.graphicsItem())
             num = 0
         self.plots.append(c)
Exemple #2
0
    def initPlotWidget(self):
        pg.setConfigOptions(useOpenGL=self.config['GUI']['openGL'],
                            useWeave=self.config['GUI']['useWeave'],
                            antialias=self.config['GUI']['antiAliasing'])
        self.plot = pg.PlotWidget()
        self.plot.setBackground(None)
        self.plot.getPlotItem().setTitle(translate('RTOC', "Signals"))
        self.plot.getPlotItem().ctrlMenu = None  # get rid of 'Plot Options'
        axis = pyqtlib.TimeAxisItem(orientation='bottom')
        axis.attachToPlotItem(
            self.plot.getPlotItem())  # THIS LINE CREATES A WARNING
        # self.plot.getPlotItem().setLabel("bottom", translate('RTOC', "Elapsed time"), "")
        self.plotLayout.addWidget(self.plot)
        self.legend = pg.LegendItem()
        self.legend.setParentItem(self.plot.getPlotItem())
        self.legend.anchor((1, 0), (1, 0), (-10, 10))
        self.plot.showGrid(x=self.grid[0], y=self.grid[1], alpha=self.grid[2])

        self.plotMouseLabel = pg.TextItem("",
                                          color=(200, 200, 200),
                                          fill=(200, 200, 200, 50),
                                          html=None)  # ,
        self.plot.addItem(self.plotMouseLabel, ignoreBounds=True)

        self.hideSignalsButton.clicked.connect(self.hideSignalList)
        toggleConsole = self.plot.getPlotItem().getViewBox().menu.addAction(
            'Toggle Console')
        toggleConsole.triggered.connect(self.toggleConsole)

        self.toggleEventButton.setChecked(
            self.logger.config['GUI']['showEvents'])
Exemple #3
0
    def plot_data(self, x, y, labels, autoSI=False):
        line = pg.PlotCurveItem(x, y, pen='b', brush='w')
        self.plot_window.addItem(line)

        # Add trendline
        z = polyfit(x, y, 1)
        p = np.poly1d(z['polynomial'])

        trend = pg.PlotCurveItem(x, p(x), pen='r', brush='w')
        self.plot_window.addItem(trend)

        self.plot_window.setBackground('w')
        self.plot_window.showGrid(x=True, y=True)

        legend = pg.LegendItem()
        legend.addItem(line, 'NDVI')
        legend.addItem(
            trend,
            self.tr('Linear trend (r<sup>2</sup> = {0:.2f})').format(
                z['determination']))
        legend.setParentItem(self.plot_window.getPlotItem())
        legend.anchor((1, 0), (1, 0))

        yaxis = self.plot_window.getPlotItem().getAxis('left')
        yaxis.enableAutoSIPrefix(autoSI)

        if labels:
            self.plot_window.setLabels(**labels)
Exemple #4
0
    def __init__(self, project):
        super().__init__()
        self.project = project
        # For testing purposes, the sample and stage is hard coded
        self.sampleName = 'Sample-1'
        self.focusStage = 'rawdata'
        # Add plot window to the layout
        graph = self.addPlot(title=self.sampleName)
        graph.setLogMode(x=False, y=True)
        graph.setLabel('left', 'Counts')
        graph.setLabel('bottom', 'Time', units='s')

        self.graph = graph

        # Add legend window to the layout
        legend = self.addViewBox()
        legend.setMaximumWidth(100)

        self.legend = legend

        l = pg.LegendItem()
        l.setParentItem(self.legend)
        l.anchor((0, 0), (0, 0))

        self.l = l
Exemple #5
0
    def __init__(self, title, labels, **kwargs):
        super().__init__(title, **kwargs)

        self.labels = labels

        self.setMinimumHeight(200)
        self.setMinimumWidth(400)

        self.plot = self.plots.addPlot()

        self.curves_hist = {}
        self.curves_fit = {}
        for i, label in enumerate(labels):
            self.curves_hist[label] = self.plot.plot([0, 1], [0],
                                                     stepMode="center",
                                                     fillLevel=0,
                                                     fillOutline=True,
                                                     brush=color_palette[i],
                                                     name=label)
            self.curves_fit[label] = self.plot.plot(pen=pg.mkPen(
                style=QtCore.Qt.DashLine,
                width=0.5,
                color=(211, 211, 211),
            ))

        self.legend = pg.LegendItem()
        self.legend.setParentItem(self.plot.graphicsItem())
        for i, label in enumerate(labels):
            self.legend.addItem(self.curves_hist[label], label)

        self.plot.setLabel('bottom', 'frequency', units='MHz')
        self.plot.setLabel('left', 'counts', units='1')
Exemple #6
0
    def _subplot(self, axis_name, units=None):

        if units is None:
            units = 'au'

        # Return subplot if it exists
        if axis_name in self.plot_items:
            return self.plot_items[axis_name]

        # Else create subplot

        # Hide x axis for previously added subplot
        if len(self.plot_items) > 0:
            self.plot_items[list(self.plot_items)[-1]].hideAxis('bottom')

        # Add new subplot
        new_plot: pg.PlotItem = self.layout_widget.addPlot(col=0, row=len(self.plot_items))
        new_plot.getViewBox().enableAutoRange(x=False)
        new_plot.setLabel('bottom', text='Time', units='s')
        new_plot.setLabel('left', text=axis_name, units=units)
        new_plot.getAxis('left').setWidth(75)
        new_plot.sigXRangeChanged.connect(self._xrange_changed)
        self.plot_items[axis_name] = new_plot

        # Add subplot toggle option
        self._add_subplot_toggle(axis_name)

        # Add legend for new plot
        new_legend = pg.LegendItem()
        new_legend.setParentItem(new_plot)
        new_legend.setOffset([80, 1])
        new_legend.setBrush(pg.mkBrush(color=(0, 0, 0, 180)))
        self.legend_items[axis_name] = new_legend

        return new_plot
Exemple #7
0
    def __build_plot_frame(self):
        """
        Creates a Qt Frame object to hold the plot UI elemets
        |-- QFrame
            |-- QVBoxLayout
                |-- Analysis Plot (PyQtGraph Graphics Layout Widget)
        :return plot_frame: QFrame
        """

        # Create a QFrame object
        plot_frame = QtWidgets.QFrame()
        plot_frame.setFrameStyle(QtWidgets.QFrame.Panel
                                 | QtWidgets.QFrame.Sunken)
        plot_frame.setMinimumWidth(200)

        # Create a QVBoxLayout to populate with UI elements
        plot_frame_layout = QtWidgets.QVBoxLayout()

        # Create the main plot window
        self.analysis_plot = analysis_ui_utils.AnalysisPlotWidget()
        self.analysis_plot.set_axis_numbers(self.axis_numbers)

        # Add a Legend to the plot
        legend = pg.LegendItem(offset=(60, 5))
        self.analysis_plot.add_legend(legend)

        # Add the plot window to the QVBoxLayout
        plot_frame_layout.addWidget(self.analysis_plot.plot_window)

        # Add the QVBoxLayout to the QFrame
        plot_frame.setLayout(plot_frame_layout)

        return plot_frame
Exemple #8
0
    def __init__(self, main):
        pg.PlotWidget.__init__(self)
        self.main = main

        self.le = pg.PlotDataItem(name='Left eye position [deg]',
                                  pen=pg.mkPen(color=(0, 0, 255, 255),
                                               width=2))
        self.addItem(self.le)

        self.re = pg.PlotDataItem(name='Right eye position [deg]',
                                  pen=pg.mkPen(color=(255, 0, 0, 255),
                                               width=2))
        self.addItem(self.re)

        self.trigger = pg.PlotDataItem(name='Trigger',
                                       pen=pg.mkPen(color=(255, 255, 0, 255),
                                                    width=2))
        self.addItem(self.trigger)

        self.flash = pg.PlotDataItem(name='Flash',
                                     pen=pg.mkPen(color=(255, 128, 0, 255),
                                                  width=2))
        self.addItem(self.flash)

        self.legend = pg.LegendItem(offset=(40, 0.9))
        #self.plotItem.addLegend()
        self.legend.addItem(self.le, self.le.name())
        self.legend.addItem(self.re, self.re.name())
        self.legend.addItem(self.trigger, self.trigger.name())
        self.legend.addItem(self.flash, self.flash.name())
        self.legend.setParentItem(self.plotItem)
Exemple #9
0
    def __init__(self, parent, name, series, **kargs):
        axisItems = {'bottom': DateAxisItem('bottom')}
        super(TimeSeriesPlot, self).__init__(parent=parent,
                                             title=name,
                                             axisItems=axisItems,
                                             **kargs)
        self.getPlotItem().showGrid(x=True, y=True)
        self.setBackground('#202020')
        self.setAntialiasing(True)
        self.setMenuEnabled(False)

        self.plot_data = {}
        self.plots = []
        self.series = series
        self.last_timestamp = 0

        legend = pg.LegendItem((150, 25 * len(series)), offset=(150, 30))
        legend.setParentItem(self.graphicsItem())

        for serie in series:
            plot = self.plot(**serie)
            self.plots.append(plot)
            legend.addItem(plot, serie['name'])

        # Limit the date range
        self.setLimits(xMin=BITTORRENT_BIRTHDAY,
                       xMax=time.time() + YEAR_SPACING)
Exemple #10
0
 def __init__(self, plot):
     Qt.QGraphicsScene.__init__(self, Qt.QGraphicsScene())
     gv = self
     self.plot = plot
     gv.setBackgroundBrush(Qt.QBrush(Qt.QColor('white')))
     self.legend = pg.LegendItem(None, offset=(0, 0))
     gv.scene().addItem(self.legend)
Exemple #11
0
    def __init__(self, parent=None):
        """Set up the ui."""
        uifile = _utils.get_ui_file(self)
        config = _configuration.MeasurementConfig()
        super().__init__(uifile, config, parent=parent)

        self.le_names = [
            'block_name',
        ]

        self.te_names = [
            'comments',
        ]

        self.sbd_names = [
            'block_temperature',
            'block_volume',
            'block_dimension1',
            'block_dimension2',
            'block_dimension3',
            'block_mass_A',
            'block_mass_B',
            'density',
        ]

        self.cmb_names = [
            'gain_position_1',
            'gain_position_2',
        ]

        self.chb_names = [
            'measure_position_1',
            'measure_position_2',
        ]

        self.connect_signal_slots()
        self.load_last_db_entry()
        self.update_volume()

        self.stop = False
        self.block_volume = None
        self.offset_position_1 = None
        self.offset_position_2 = None
        self.integrated_voltage = []
        self.integrated_voltage_position_1 = []
        self.integrated_voltage_position_2 = []
        self.graph_position_1 = []
        self.graph_position_2 = []
        self.measurement_data = _measurement.MeasurementData()
        self.measurement_error_count = 0
        self.mx_list = []
        self.my_list = []
        self.mz_list = []

        self.legend = _pyqtgraph.LegendItem(offset=(70, 30))
        self.legend.setParentItem(self.ui.pw_graph.graphicsItem())
        self.legend.setAutoFillBackground(1)

        self.configure_gui_visualization()
Exemple #12
0
    def _add_legend(self):
        legend = pg.LegendItem((140, 100), offset=(10, 10))
        legend.setParentItem(self.chart.getPlotItem())

        for arr, item in self.curves:
            legend.addItem(
                SampleLegendItem(item), item.opts['name']
                if not isinstance(item, tuple) else item[0].opts['name'])
Exemple #13
0
 def createPlotWidget(self):
     """
     Creates the plotWidget
     """
     self.vbLayout=QVBoxLayout(self)
     self.plotLayout=pg.LayoutWidget()
     self.vbLayout.addWidget(self.plotLayout)
     
     row=0
     col=0
     lineWidthLabel=QLabel('Line width')
     self.lineWidthLineEdit=QLineEdit('2')
     self.lineWidthLineEdit.returnPressed.connect(self.updatePlot)
     pointSizeLabel=QLabel('Point size')
     self.pointSizeLineEdit=QLineEdit('5')
     self.pointSizeLineEdit.returnPressed.connect(self.updatePlot)
     self.bgCheckBox=QCheckBox('White BG')
     self.bgCheckBox.stateChanged.connect(self.bgCheckBoxChanged)
     self.errorbarCheckBox=QCheckBox('Errorbar')
     self.errorbarCheckBox.stateChanged.connect(self.errorbarChanged)
     self.plotLayout.addWidget(lineWidthLabel,row=row,col=col)
     col+=1
     self.plotLayout.addWidget(self.lineWidthLineEdit,row=row,col=col)
     col+=1
     self.plotLayout.addWidget(pointSizeLabel,row=row,col=col)
     col+=1
     self.plotLayout.addWidget(self.pointSizeLineEdit,row=row,col=col)
     col+=1
     self.plotLayout.addWidget(self.bgCheckBox,row=row,col=col)
     col+=1
     self.plotLayout.addWidget(self.errorbarCheckBox,row=row,col=col)
     col=0
     row+=1
     if self.matplotlib:
         self.plotWidget=MatplotlibWidget()
         self.subplot=self.plotWidget.getFigure().add_subplot(111)
         self.plotWidget.fig.set_tight_layout(True)
         self.plotWidget.draw()
     else:
         self.plotWidget=pg.PlotWidget()
         self.plotWidget.getPlotItem().vb.scene().sigMouseMoved.connect(self.mouseMoved)
         self.legendItem=pg.LegendItem(offset=(0.0,1.0))
         self.legendItem.setParentItem(self.plotWidget.getPlotItem())
         
     self.plotLayout.addWidget(self.plotWidget,row=row,col=col,colspan=6)
     row+=1
     col=0 
     self.crosshairLabel=QLabel(u'X={: .5f} , y={: .5f}'.format(0.0,0.0))                                 
     self.xLogCheckBox=QCheckBox('LogX')
     self.xLogCheckBox.setTristate(False)
     self.xLogCheckBox.stateChanged.connect(self.updatePlot)
     self.yLogCheckBox=QCheckBox('LogY')
     self.yLogCheckBox.setTristate(False)
     self.yLogCheckBox.stateChanged.connect(self.updatePlot)
     if not self.matplotlib:
         self.plotLayout.addWidget(self.crosshairLabel,row=row,col=col,colspan=4)
     self.plotLayout.addWidget(self.xLogCheckBox,row=row,col=4)
     self.plotLayout.addWidget(self.yLogCheckBox,row=row,col=5)
Exemple #14
0
    def initUI(self):
        uic.loadUi("inference_viewer.ui", self)
        self.setStyleSheet("background-color: white")
        self.name_label.setText("Model: %s" % (self.model_name))
        self.cpuName_label.setText(self.cpu_name)
        self.gpuName_label.setText(self.gpu_name)
        self.dataset_label.setText("Augmentation set - %d" % (self.rali_mode))
        self.imagesFrame.setStyleSheet(
            ".QFrame {border-width: 20px; border-image: url(./data/images/filmStrip.png);}"
        )
        self.total_progressBar.setStyleSheet(
            "QProgressBar::chunk { background: lightblue; }")
        self.top1_progressBar.setStyleSheet(
            "QProgressBar::chunk { background: green; }")
        self.top5_progressBar.setStyleSheet(
            "QProgressBar::chunk { background: lightgreen; }")
        self.mis_progressBar.setStyleSheet(
            "QProgressBar::chunk { background: red; }")
        self.total_progressBar.setMaximum(self.total_images *
                                          self.batch_size_int)
        self.graph = pg.PlotWidget(title="Accuracy vs Time")
        self.graph.setLabel('left', 'Accuracy', '%')
        self.graph.setLabel('bottom', 'Time', 's')
        self.graph.setYRange(0, 100, padding=0)
        pg.setConfigOptions(antialias=True)
        self.totalCurve = self.graph.plot(pen=self.pen)
        self.augCurve = self.graph.plot(pen=pg.mkPen('b', width=4))
        self.legend = pg.LegendItem(offset=(370, 1))
        self.legend.setParentItem(self.graph.plotItem)
        self.legend.addItem(self.totalCurve, 'Cumulative')
        self.graph.setBackground(None)
        self.graph.setMaximumWidth(550)
        self.graph.setMaximumHeight(300)
        self.verticalLayout_2.addWidget(self.graph)
        self.level_slider.setMaximum(100)
        self.level_slider.valueChanged.connect(self.setIntensity)
        self.pause_pushButton.setStyleSheet(
            "color: white; background-color: darkBlue")
        self.stop_pushButton.setStyleSheet(
            "color: white; background-color: darkRed")
        self.pause_pushButton.clicked.connect(self.pauseView)
        self.stop_pushButton.clicked.connect(self.terminate)
        self.dark_checkBox.stateChanged.connect(self.setBackground)
        self.verbose_checkBox.stateChanged.connect(self.showVerbose)
        self.rali_checkBox.stateChanged.connect(self.showRALI)
        self.dark_checkBox.setChecked(True)
        self.graph_imageLabel.setPixmap(self.graph_image_pixmap)
        if self.container_index == 1:
            self.container_logo.setPixmap(self.docker_pixmap)
        elif self.container_index == 2:
            self.container_logo.setPixmap(self.singularity_pixmap)
        else:
            self.container_logo.hide()
        for augmentation in range(self.batch_size_int):
            self.augAccuracy.append([0])

        self.showVerbose()
        self.showRALI()
Exemple #15
0
    def plot_frame(self):
        if self.loaded:
            self.titles[0].setText('difference')
            self.titles[1].setText('merged')
            self.titles[2].setText('top')
            iPC = int(self.PCedit.text()) - 1
            pc1 = self.PC[1, iPC, :, :]
            pc0 = self.PC[0, iPC, :, :]
            diff = pc1[:, :, np.newaxis] - pc0[:, :, np.newaxis]
            diff /= np.abs(diff).max() * 2
            diff += 0.5
            self.img0.setImage(np.tile(diff * 255, (1, 1, 3)))
            self.img0.setLevels([0, 255])
            rgb = np.zeros((self.PC.shape[2], self.PC.shape[3], 3), np.float32)
            rgb[:, :, 0] = (pc1 - pc1.min()) / (pc1.max() - pc1.min()) * 255
            rgb[:, :, 1] = np.minimum(
                1, np.maximum(0, (pc0 - pc1.min()) /
                              (pc1.max() - pc1.min()))) * 255
            rgb[:, :, 2] = (pc1 - pc1.min()) / (pc1.max() - pc1.min()) * 255
            self.img1.setImage(rgb)
            if self.cframe == 0:
                self.img2.setImage(np.tile(pc0[:, :, np.newaxis], (1, 1, 3)))
            else:
                self.img2.setImage(np.tile(pc1[:, :, np.newaxis], (1, 1, 3)))
            self.img2.setLevels([pc0.min(), pc0.max()])
            self.zoom_plot()
            self.p3.clear()
            p = [(200, 200, 255), (255, 100, 100), (100, 50, 200)]
            ptitle = ['rigid', 'nonrigid', 'nonrigid max']
            if not hasattr(self, 'leg'):
                self.leg = pg.LegendItem((100, 60), offset=(350, 30))
                self.leg.setParentItem(self.p3)
                drawLeg = True
            else:
                drawLeg = False
            for j in range(3):
                cj = self.p3.plot(np.arange(1, self.nPCs + 1),
                                  self.DX[:, j],
                                  pen=p[j])
                if drawLeg:
                    self.leg.addItem(cj, ptitle[j])
                self.nums[j].setText('%s: %1.3f' %
                                     (ptitle[j], self.DX[iPC, j]))
            self.scatter = pg.ScatterPlotItem()
            self.p3.addItem(self.scatter)
            self.scatter.setData([iPC + 1, iPC + 1, iPC + 1],
                                 self.DX[iPC, :].tolist(),
                                 size=10,
                                 brush=pg.mkBrush(255, 255, 255))
            self.p3.setLabel('left', 'pixel shift')
            self.p3.setLabel('bottom', 'PC #')

            self.p4.clear()
            self.p4.plot(self.tPC[:, iPC])
            self.p4.setLabel('left', 'magnitude')
            self.p4.setLabel('bottom', 'time')
            self.show()
            self.zoom_plot()
 def init_graph(self):
     temp = str(self.itemText).split(' - ')
     self.ui.hour_label.show()
     self.ui.hour_value.show()
     self.ui.minutes_label.show()
     self.ui.minutes_value.show()
     if len(temp) > 1:
         self.attr = temp[1]
         with open('graph_config', 'r') as fin:
             graph_nodes = json.loads(fin.read())
             current_graph_node = graph_nodes[str(self.itemText)]
             total_graph_values = int(
                 current_graph_node['total_graph_values'])
             graph_updation_time = int(
                 current_graph_node['graph_updation_time'])
             print "----init_graph----"
             print "total_graph_values:", total_graph_values
             print "graph_updation_time:", graph_updation_time
     elif len(temp) == 1:
         self.attr = str(self.ui.childrenBox.currentText())
         with open('graph_config', 'r') as fin:
             graph_nodes = json.loads(fin.read())
             current_graph_node = graph_nodes[str(self.itemText)]
             self.total_graph_values = int(
                 current_graph_node['total_graph_values'])
             graph_updation_time = int(
                 current_graph_node['graph_updation_time'])
             print "----init_graph----"
             print "total_graph_values:", self.total_graph_values
             print "graph_updation_time:", graph_updation_time
         self.branch_time_array = []
         self.branch_axis_counter = 0
     pg.setConfigOptions(antialias=True)
     self.ui.graphicsView.clear()
     self.curve = self.ui.graphicsView.plot(pen='y')
     try:
         self.l.scene().removeItem(self.l)
     except AttributeError:
         pass
     self.l = pg.LegendItem((100, 60), offset=(70, 30))
     self.l.setParentItem(self.ui.graphicsView.graphicsItem())
     self.l.addItem(self.curve, self.attr)
     self.data = []
     self.ptr = 0
     if len(temp) > 1:
         self.proxy = DeviceProxy(temp[0])
         params = json.dumps({'period': 1})
         data = json.loads(self.proxy.get_data(params))
         data = data[self.attr]
         data_len = len(data)
         self.data_period = total_graph_values / data_len
     else:
         self.proxy = ''
     self.graphTimer.stop()
     self.graphTimer.timeout.connect(self.update_plot)
     self.graphTimer.start(graph_updation_time)
Exemple #17
0
    def __init__(self, buffer_size=10):

        self.win = pg.plot()
        self.plots = {}
        self.data_x = {}
        self.data_y = {}
        self.legend = pg.LegendItem((80, 60), offset=(70, 20))
        self.legend.setParentItem(self.win.graphicsItem())
        self.time = time.time()
        self.named_value_buffer = queue.Queue(buffer_size)
Exemple #18
0
 def _add_legend(self):
     layout = self.centralWidget()
     p = layout.addPlot(row=2, col=1)
     p.hideAxis("left")
     p.hideAxis("bottom")
     legend = pg.LegendItem()
     self._customize_legend(legend)
     legend.setParentItem(p)
     for l, n in zip(self.lines, self.rppg.processor_names):
         legend.addItem(l, n)
Exemple #19
0
	def addPlotArea(self, graphTitle = ''):
		viewBox  = CustomViewBox()
		plotArea = self.view.addPlot( viewBox = viewBox, enableMenu = False, title = graphTitle)
		legend   = pg.LegendItem((100,60), offset=(70,70))  # args are (size, offset)
		
		legend.setParentItem(plotArea.graphicsItem())   # Note we do NOT call plt.addItem in this case
		self.view.nextRow()
		viewBoxNum = self.addPlotHolder(plotArea, legend, viewBox)
		plotArea.viewBoxNum = viewBoxNum
		return plotArea, legend, viewBox#self.w, self.l
    def initUI(self):
        ''' Define display style '''
        
        self.showMaximized()
        self.setBackground(None)
        
        # Set layout to a QGridLayout, so you only need to define row and column
        self.layout = QtWidgets.QGridLayout()
        self.setLayout(self.layout)

        # Add Widgets to the layout    
        self.btnStop = QtGui.QPushButton('Stopp')
        self.btnStop.clicked.connect(self.stopStreaming)
        self.layout.addWidget(self.btnStop, 0,0)
        
        self.check = QtWidgets.QCheckBox('Daten speichern')
        self.check.stateChanged.connect(self.checked)
        self.layout.addWidget(self.check, 2,0) 
          
        self.cbox = QtWidgets.QComboBox()
        self.cbox.addItems(['bitte waehlen', 'Accelerometer', 'Gyroscope'])
        self.layout.addWidget(self.cbox, 2,2)
        self.cbox.currentIndexChanged.connect(self.selectionChange)
        
        self.layout.addWidget(QtWidgets.QLabel('Messung:'), 1,2) 
        
        # Create a plot with a legend next to it
        self.p1 = pg.plot()
        self.p1.win.hide()
        self.p1.showGrid(x=True, y=True)
        self.p1.setLabel('bottom','Zeit')
        
        # Create a curve to plot
        self.curveX = self.p1.plot(pen='r')                       
        self.curveY = self.p1.plot(pen='g')
        self.curveZ = self.p1.plot(pen='c')
        
        self.vb = self.addViewBox()  # Empty box next to the plot
        self.vb.setMaximumWidth(3000)
        self.legend = pg.LegendItem()
        self.legend.setParentItem(self.vb)
        
        self.legend.addItem(self.curveX, 'x-data')
        self.legend.addItem(self.curveY, 'y-data')
        self.legend.addItem(self.curveZ, 'z-data')
        
        # Anchor the upper-left corner of the legend to the upper-left corner of its parent
        self.legend.anchor((-24.5,0),(0,0))
        
        # Add the plot to the window
        self.layout.addWidget(self.p1, 0,1)
        
        # Define width of several columns
        self.layout.setColumnStretch(1, 3)
Exemple #21
0
 def addPlotArea(self, graphTitle=''):
     self.vb = CustomViewBox()
     self.w = self.view.addPlot(viewBox=self.vb,
                                enableMenu=False,
                                title=graphTitle)
     self.view.nextRow()
     self.l = pg.LegendItem((100, 60),
                            offset=(70, 70))  # args are (size, offset)
     self.l.setParentItem(self.w.graphicsItem()
                          )  # Note we do NOT call plt.addItem in this case
     return self.w, self.l
Exemple #22
0
    def set_legend(self):
        '''Adds the legend handle to the widget'''

        items = legends.get_legend(self.group, self.indexes, self.plotdata)
        if items is not None:
            # anchor top-left
            self.labels = pg.LegendItem()
            self.labels.setParentItem(self.viewbox)
            self.labels.anchor((0, 0), parentPos=(0, 0), offset=(30, 30))

            for index, item in enumerate(items):
                self.labels.addItem(self.plots[index], item)
Exemple #23
0
    def createLegend(self):
        pen = pg.mkPen(color=(0, 0, 0), width=1.0)
        brush = pg.mkBrush(color=(255, 255, 255))
        legend = pg.LegendItem(offset=(60, 10),
                               verSpacing=-0.5,
                               pen=pen,
                               brush=brush,
                               frame=True)  #, colCount=2)
        legend.setLabelTextColor((0, 0, 0))  # black text
        # legend.setParentItem(plotItem)

        return legend
    def __init__(self, parent=None):
        super().__init__(parent)

        self.classes = []

        self.data = None
        self.annotation_variables = []
        self.__groups = None
        self.__selected_data_indices = []

        # Setup GUI
        infobox = gui.widgetBox(self.controlArea, "Info")
        self.infoLabel = gui.widgetLabel(infobox, "No data on input.")
        displaybox = gui.widgetBox(self.controlArea, "Display")
        gui.checkBox(displaybox,
                     self,
                     "display_individual",
                     "Expression Profiles",
                     callback=self.__update_visibility)
        gui.checkBox(displaybox,
                     self,
                     "display_quartiles",
                     "Quartiles",
                     callback=self.__update_visibility)

        group_box = gui.widgetBox(self.controlArea, "Classes")
        self.group_listbox = gui.listBox(
            group_box,
            self,
            "selected_classes",
            "classes",
            selectionMode=QListWidget.MultiSelection,
            callback=self.__on_class_selection_changed)
        self.unselectAllClassedQLB = gui.button(
            group_box, self, "Unselect all", callback=self.__select_all_toggle)

        self.annot_cb = gui.comboBox(self.controlArea,
                                     self,
                                     "annot_index",
                                     box="Profile Labels",
                                     callback=self.__update_tooltips)

        gui.rubber(self.controlArea)
        gui.auto_commit(self.controlArea, self, "auto_commit", "Commit")

        self.graph = pg.PlotWidget(background="w")
        self.graph.setRenderHint(QPainter.Antialiasing, True)
        self.graph.scene().selectionChanged.connect(
            self.__on_curve_selection_changed)
        self.mainArea.layout().addWidget(self.graph)
        self.legend = pg.LegendItem(offset=(-30, 30))
        self.legend.setParentItem(self.graph.plotItem)
        self.legend_items = []
Exemple #25
0
    def set_ppm(self, bounds=None):
        '''Adds the ppm handle to the widget'''

        ppms = legends.get_ppm(self.group, self.indexes, self.plotdata, bounds)
        if ppms is not None:
            # anchor top-right
            self.ppm = pg.LegendItem()
            self.ppm.setParentItem(self.viewbox)
            self.ppm.anchor((1, 0), parentPos=(1, 0), offset=(-30, 30))

            for index, ppm in enumerate(ppms):
                self.ppm.addItem(self.plots[index], ppm)
Exemple #26
0
    def __init__(self, parent=None, **kargs):
        pg.GraphicsWindow.__init__(self, **kargs)
        self.setParent(parent)
        self.p = self.addPlot(labels={'left': 'Amplitude', 'bottom': 'z'})

        ing = 300
        x1 = np.linspace(0, cgs.L, ing + 1)
        self.data = np.zeros(ing + 1)
        self.data1 = []

        x2 = np.linspace(0, cgs.L, self.K + 1)
        #print(x2.shape)
        for i in range(ing + 1):
            self.data[i] = slv.main_sum(6 * self.y / self.J, 4 * i / self.K)

        v = (cgs.mainsolve(self.J, self.K))
        #print(v.shape)
        #print("fqwefweqf")
        self.data1 = abs(v[0, :])

        #print(self.data1)
        #print(x2)

        self.curve = self.p.plot(x1,
                                 self.data,
                                 pen=(16, 41, 89),
                                 symbolBrush=(16, 41, 89))  #аналитическоя
        self.curve1 = self.p.plot(x2, (self.data1),
                                  pen=(242, 219, 8),
                                  symbolBrush=(242, 219, 8))  #cage

        self.p.setYRange(0.0, 10)
        #self.p.setXRange(0,0.2)

        #self.p.setXRange(0.17,0.22)
        #self.p.setXRange(0,0.001)

        l = pg.LegendItem((100, 60), offset=(650, 30))
        l.setParentItem(self.p)
        #l.addItem(self.curve, 'Аналитическое решение')
        l.addItem(self.curve1, 'Численное решение')

        self.p.showGrid(x=True, y=True)
        self.p.setLabel("left", text='Amplitude', units="a")
        self.p.setLabel("bottom", text='Z', units="s")

        #self.p.setYRange(20,21)
        #o = self.p.getAxis()
        #n = self.p.getAxis("bottom")

        timer = pg.QtCore.QTimer(self)
        timer.timeout.connect(self.update)
        timer.start(1)
Exemple #27
0
    def __init__(self, name, statNames, sarData, *args, **kwargs):
        pg.PlotWidget.__init__(self, *args, **kwargs)

        self.title = name
        self.statNames = statNames
        self.sarData = sarData
        self.layout = QGridLayout(self)

        self.legend = pg.LegendItem()
        self.addItem(self.legend)

        self.initialize()
Exemple #28
0
    def __init__(self):
        pg.PlotWidget.__init__(self)

        # Setup Field Plot
        self.setAspectLocked()
        self.showGrid(x=True, y=True, alpha=0.4)

        # Setup Field Plot Legend
        self.legend = pg.LegendItem((80, 60), offset=(70, 20))
        self.legend.setParentItem(self.graphicsItem())

        # Fields
        self.layers = []
    def __init__(self,bigY,bigX,*args,**kwargs):
        pg.PlotWidget.__init__(self,*args,**kwargs)

        self.ploot = self.plot()
        self.Y = bigY #Speed
        self.X = bigX #Temperature
        self.opendir = ""
        self.errorbars = pg.ErrorBarItem(x = 0,y=0,pen=None)
        self.legendo = pg.LegendItem()
        self.getViewBox().addItem(self.errorbars)
        self.addItem(self.legendo)
        self.errorbars.hide()
        self.getViewBox().setAutoVisible()
 def create_legend(self):
     self.legends.clear()
     for i in range(self.DM.get_subplots_num()):
         self.legends.append(None)
         for j in range(self.DM.get_plots_num(i)):
             pl_sett = self.DM.get_plot_setting(i, j)
             if pl_sett['title'] is not None:
                 if self.legends[i] is None:
                     legend = pg.LegendItem(offset=(60, 20))
                     self.legends[i] = legend
                     self.legends[i].setParentItem(self.subplots_data[i])
                 self.legends[i].addItem(self.plots_data[i][j],
                                         name=pl_sett['title'])