def __init__(self): super().__init__() self.mdi = QMdiArea() self.setCentralWidget(self.mdi) bar = self.menuBar() self.current_dir = None file = bar.addMenu("File") file.addAction("New") file.addAction("cascade") file.addAction("Tiled") file.triggered[QAction].connect(self.WindowTrig) load = bar.addMenu("Load") load.addAction("2D") load.addAction("3D") load.triggered[QAction].connect(self.dir_open) self.setWindowTitle("MDI Application") self.base_wd = QMdiSubWindow() self.base_wd.plt_i = pg.PlotItem(labels={ 'bottom': ('slits', 'degrees'), 'left': ('Kin. Energy', 'eV') }) self.base_wd.plt_iv = pg.ImageView(view=self.base_wd.plt_i) self.base_wd.setWidget(self.base_wd.plt_iv) self.base_wd.setWindowTitle("plot window") self.mdi.addSubWindow(self.base_wd) self.base_wd.show() data_DockWidget = QDockWidget('data', self) data_DockWidget.setObjectName(('data window')) data_DockWidget.setAllowedAreas(Qt.RightDockWidgetArea) self.data_list = QListWidget() data_DockWidget.setWidget(self.data_list) self.addDockWidget(Qt.RightDockWidgetArea, data_DockWidget) self.data_list.itemClicked.connect(self.show_data) self.data_list.itemDoubleClicked.connect(self.get_data)
def initialize_plot(self): if self.controller.some_waveforms is None: return 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.curve1 = pg.PlotCurveItem() #~ self.plot.addItem(self.curve1) #~ self.curve2 = pg.PlotCurveItem() #~ self.plot.addItem(self.curve2) self.curves = [] thresh = self.controller.get_threshold() self.thresh_line = pg.InfiniteLine(pos=thresh, angle=0, movable=False, pen = pg.mkPen('w')) self.plot.addItem(self.thresh_line) self.params.blockSignals(True) #~ self.params['bin_min'] = np.min(self.controller.some_waveforms) #~ self.params['bin_max'] = np.max(self.controller.some_waveforms) #~ print(self.controller.some_waveforms.shape) #~ print(self.controller.some_peaks_index.shape) #~ print(self.controller.some_peaks_index) #~ print(self.controller.spike_label[self.controller.some_peaks_index].shape) keep = self.controller.spike_label[self.controller.some_peaks_index]>=0 wfs = self.controller.some_waveforms[keep, :, :] if wfs.shape[0]>0: self.params['bin_min'] = np.percentile(wfs, .001) self.params['bin_max'] = np.percentile(wfs, 99.999) self.params.blockSignals(False)
def plotLineGraphItem(self,name,lstX=[],lstY=[]): p = pg.PlotItem(title=name) if len(lstX)==0: return p i = 0 ticklist = [] for x in lstX: ticklist.append((x, "%.2f"%(x))) if lstY[i] > 0: k = 0.5 else: k = 0 text = pg.TextItem(html='<div style="text-align: center"><span style="color: #FFF;">'+ "%.1f"%(lstY[i]) + '</span><br></div>', anchor=(0.5,k), angle=0) p.addItem(text) text.setPos(x,lstY[i]) i = i + 1 p.plot(lstX, lstY, symbol='o',symbolBrush=(255,0,0)) p.getAxis("bottom").setTicks([ticklist,[]]) return p
def makePI(self, name): """生成PlotItem对象""" vb = CustomViewBox() plotItem = pg.PlotItem(viewBox=vb, name=name, axisItems={'bottom': self.axisTime}) plotItem.setMenuEnabled(False) plotItem.setClipToView(True) plotItem.hideAxis('left') plotItem.showAxis('right') plotItem.setDownsampling(mode='peak') plotItem.setRange(xRange=(0, 1), yRange=(0, 1)) plotItem.getAxis('right').setWidth(60) plotItem.getAxis('right').setStyle( tickFont=QFont("Roman times", 10, QFont.Bold)) plotItem.getAxis('right').setPen(color=(255, 255, 255, 255), width=0.8) plotItem.showGrid(True, True) plotItem.hideButtons() return plotItem
def __init__(self, **kargs): WidgetNode.__init__(self, **kargs) self.layout = QtGui.QHBoxLayout() self.setLayout(self.layout) self.graphicsview = pg.GraphicsView() self.layout.addWidget(self.graphicsview) self.plot = pg.PlotItem() self.graphicsview.setCentralItem(self.plot) self.plot.getViewBox().setAspectLocked(lock=True, ratio=1) self.plot.hideButtons() self.plot.showAxis('left', False) self.plot.showAxis('bottom', False) self.image = pg.ImageItem() self.plot.addItem(self.image)
def addPlot(self): self.resetAll() self.plotList = [] self.zoomTarget = len(self.plotNameList) - 1 for cnt in self.plotNameList: self.plotList.append(pg.PlotItem()) for cnt in range(len(self.plotList)): self.win.addItem(self.plotList[cnt], row=cnt + 1, col=0) for cnt in range(len(self.plotList) - 1): title = str(self.plotNameList[cnt]) unit = "V" if title.startswith("CH") else None self.plotList[cnt].setLabel('left', title, units=unit) self.plotList[cnt].showGrid(x=True, y=True) self.plotList[self.zoomTarget].setLabel( 'left', "Navigator{" + str(self.plotList[self.target]) + ")") return self.plotList
def __init__(self, **kargs): WidgetNode.__init__(self, **kargs) self.layout = QtGui.QVBoxLayout() self.setLayout(self.layout) self.graphicsview = pg.GraphicsView() self.layout.addWidget(self.graphicsview) # create graphic view and plot item self.viewBox = MyViewBox() self.plot = pg.PlotItem(viewBox=self.viewBox) self.graphicsview.setCentralItem(self.plot) self.plot.hideButtons() self.plot.showAxis('left', False) self.plot.showAxis('bottom', False) self.all_mean, self.all_sd = None, None
def _setupViews(self, lut, showHistogram): """ Creates the UI widgets. """ self.mainWidget = QtWidgets.QWidget() self.setCentralWidget(self.mainWidget) self.mainLayout = QtWidgets.QVBoxLayout() self.mainWidget.setLayout(self.mainLayout) self.plotItem = pg.PlotItem() viewBox = self.plotItem.getViewBox() viewBox.disableAutoRange(pg.ViewBox.XYAxes) self.imageItem = pg.ImageItem() self.imageItem.setLookupTable(lut) self.plotItem.addItem(self.imageItem) self.colorLegendItem = ColorLegendItem( imageItem=self.imageItem, showHistogram=showHistogram, #histHeightPercentile=99.0, # Uncomment to discard the outliers in the histogram height label='Random data') self.colorLegendItem.setMinimumHeight(60) self.graphicsLayoutWidget = pg.GraphicsLayoutWidget() self.graphicsLayoutWidget.addItem(self.plotItem, 0, 0) self.graphicsLayoutWidget.addItem(self.colorLegendItem, 0, 1) self.mainLayout.addWidget(self.graphicsLayoutWidget) # Toolbar self.imgToolBar = QtWidgets.QToolBar("Tool Bar", self) self.setObjectName("toolbar") self.imgToolBar.setFloatable(False) self.imgToolBar.setAllowedAreas(QtCore.Qt.TopToolBarArea | QtCore.Qt.BottomToolBarArea) self.imgLevelsConfigWidget = ImageLevelsConfigWidget( self.colorLegendItem, label="Color Range") self.imgToolBar.addWidget(self.imgLevelsConfigWidget) self.addToolBar(QtCore.Qt.TopToolBarArea, self.imgToolBar) self.viewMenu.addAction(self.imgToolBar.toggleViewAction())
def __init__(self, *args, **kwargs): if kwargs.get("view", None) is None: kwargs["view"] = pg.PlotItem() self.plotWidget = FakePlotWidget() self.plotWidget.plotItem = kwargs["view"] super(ImageViewWithPlotItemContainer, self).__init__(*args, **kwargs) self.timeLine.setPen(pg.mkPen('k')) auto = self.ui.histogram.item.vb.menu.addAction("Autoscale Histogram") auto.triggered.connect( lambda: self.ui.histogram.item.imageChanged(True)) self.view.removeItem(self.roi) self.roi = pg.LineSegmentROI([(0, 0), (0, 10)]) self.roi.setZValue(20) self.view.addItem(self.roi) self.roi.hide() self.roi.sigRegionChanged.connect(self.roiChanged) self.roiCurve.setPen('k')
def configure_plot_type(self, plot_type): self.mainWin.plot_type = plot_type if plot_type in plot_curve_type: if self.mainWin.guiplot_count == 0: self.mainWin.guiplot = pg.PlotWidget() self.mainWin.grid.addWidget( self.mainWin.guiplot, self.mainWin.guiplot_grid_fromRow, self.mainWin.guiplot_grid_fromColumn, self.mainWin.guiplot_grid_rowSpan, self.mainWin.guiplot_grid_columnSpan) try: self.mainWin.imageCrossHair.clear() except: pass self.mainWin.image_plot_count = 0 elif plot_type in plot_image_type: self.get_colormap(self.mainWin) if self.mainWin.image_plot_count == 0: self.mainWin.plt = pg.PlotItem() self.mainWin.guiplot = pg.ImageView(view=self.mainWin.plt) self.mainWin.grid.addWidget( self.mainWin.guiplot, self.mainWin.guiplot_grid_fromRow, self.mainWin.guiplot_grid_fromColumn, self.mainWin.guiplot_grid_rowSpan, self.mainWin.guiplot_grid_columnSpan) self.mainWin.guiplot_count = 0 try: self.mainWin.CurCrossHair.clear() except: pass elif plot_type in plot_surface_type: self.get_colormap(self.mainWin) self.mainWin.guiplot = gl.GLViewWidget() self.mainWin.grid.addWidget(self.mainWin.guiplot, self.mainWin.guiplot_grid_fromRow, self.mainWin.guiplot_grid_fromColumn, self.mainWin.guiplot_grid_rowSpan, self.mainWin.guiplot_grid_columnSpan) self.mainWin.image_plot_count = 0 self.mainWin.guiplot_count = 0
def create_grid(self): color = self.params['background_color'] self.graphiclayout.clear() self.plots = [None] * self.nb_channel self.images = [None] * self.nb_channel r, c = 0, 0 nb_visible = sum(self.by_channel_params.children()[i]['visible'] for i in range(self.nb_channel)) rowspan = self.params['nb_column'] colspan = nb_visible // self.params['nb_column'] self.graphiclayout.ci.currentRow = 0 self.graphiclayout.ci.currentCol = 0 for i in range(self.nb_channel): if not self.by_channel_params.children()[i]['visible']: continue viewBox = MyViewBox() if self.with_user_dialog: viewBox.doubleclicked.connect(self.show_params_controller) viewBox.gain_zoom.connect(self.clim_zoom) viewBox.xsize_zoom.connect(self.xsize_zoom) plot = pg.PlotItem(viewBox=viewBox) plot.hideButtons() plot.showAxis('left', self.params['show_axis']) plot.showAxis('bottom', self.params['show_axis']) if self.params['display_labels']: plot.setTitle(self.channel_names[i]) else: plot.setTitle(None) self.graphiclayout.ci.layout.addItem(plot, r, c) # , rowspan, colspan) if r not in self.graphiclayout.ci.rows: self.graphiclayout.ci.rows[r] = {} self.graphiclayout.ci.rows[r][c] = plot self.graphiclayout.ci.items[plot] = [(r, c)] self.plots[i] = plot c += 1 if c == self.params['nb_column']: c = 0 r += 1
def __init__(self, stock_info): super().__init__() #cs通信 self.client_model = ClientModel.getInstance() #log #self.logger = MyLogger().get_logger() #默认stock code: 600519 self.stock_code = stock_info[0] self.setWindowTitle("A股股票历史走势K线图") self.main_widget = QtWidgets.QWidget() # 创建一个主部件 self.main_layout = QtWidgets.QGridLayout() # 创建一个网格布局 self.main_widget.setLayout(self.main_layout) # 设置主部件的布局为网格 self.setCentralWidget(self.main_widget) # 设置窗口默认部件 self.info_header = QtWidgets.QLineEdit() # 创建一个股票代码显示 self.info_header.setReadOnly(True) self.info_header.setText('股票代码:'+stock_info[0]+' 股票名称:'+stock_info[1]) self.option_sel = QtWidgets.QComboBox() # 创建一个下拉框部件 self.option_sel.addItem("近60天") self.option_sel.addItem("近180天") self.option_sel.addItem("近360天") self.que_btn = QtWidgets.QPushButton("查询") # 创建一个按钮部件 self.k_widget = QtWidgets.QWidget() # 实例化一个widget部件作为K线图部件 self.k_layout = QtWidgets.QGridLayout() # 实例化一个网格布局层 self.k_widget.setLayout(self.k_layout) # 设置K线图部件的布局层 self.k_plt_window = pg.GraphicsWindow() self.label = pg.LabelItem() #self.label.setFixedWidth(300) self.k_plt_window.addItem(self.label) self.k_plt = pg.PlotItem() # 实例化一个绘图部件 self.k_plt_window.addItem(self.k_plt, row = 1, col = 0) self.k_layout.addWidget(self.k_plt_window) # 添加绘图部件到K线图部件的网格布局层 # 将上述部件添加到布局层中 self.main_layout.setContentsMargins(0, 0, 0, 0) self.main_layout.addWidget(self.info_header,0,0,1,1) self.main_layout.addWidget(self.option_sel,0,1,1,1) self.main_layout.addWidget(self.que_btn,0,2,1,1) self.main_layout.addWidget(self.k_widget,1,0,3,3) self.que_btn.clicked.connect(self.query_slot) # 绑定按钮点击信号
def mostrar_xrd(self): layout = QVBoxLayout() try: img = (self.stack) win = QMainWindow(self) widget = QWidget() win.setWindowTitle('XRD Image') imv = pg.ImageView(view=pg.PlotItem()) imv.view.invertY(False) layout.addWidget(imv) imv2 = pg.ImageView() layout.addWidget(imv2) layout.setStretch(0, 5) layout.setStretch(1, 5) widget.setLayout(layout) win.setCentralWidget(widget) win.show() imv.setImage(img) imv.ui.roiBtn.hide() imv.ui.menuBtn.hide() def hoverEvent(event): # funcao para obter o pixel do mouse if event.isExit(): return else: pos = event.pos() i, j = pos.y(), pos.x() i = int(np.clip(i, 0, img.shape[0] - 1)) j = int(np.clip(j, 0, img.shape[1] - 1)) val = img[i, j] imv2.setImage(self.dados[i][j], levels=[0, 1]) imv.imageItem.hoverEvent = hoverEvent except IndexError: pass
def __init__(self, parent=None): super(altitudeGraphDisplayWidget, self).__init__(parent) pg.setConfigOption('background', 'k') pg.setConfigOption('foreground', 'w') self.view = pg.GraphicsView() self.graphpaper = pg.PlotItem() self.view.setCentralWidget(self.graphpaper) self.PenStyle = {'width': 3, 'color': (255, 255, 255)} layout = QtGui.QVBoxLayout() layout.addWidget(self.view) self.setLayout(layout) self.show() self.TimeData = [] self.AltitudeData = [] self.VelocityData = [] self.alt = 0 self.t = 0 self.newData.connect(self.update)
def createSubGraphs(self, text, state): text = str(text) number = int(text.split(' ')[2]) if state: if not number in self.graphs.iterkeys(): self.graphs[text] = pg.PlotItem(name=str(number)) self.capture.pDict[text] = Parameters() col = number % 3 row = 1 + number // 3 self.gLayout.addItem(self.graphs[text], row=row, col=col) self.scansToFit.add(text) else: if text in self.graphs.iterkeys(): self.gLayout.removeItem(self.graphs[text]) self.scansToFit.remove(text)
def initheatmap(self): #casts z as array for creating heatmap z = np.asarray(self.z) #recasting data in z as integers z.astype(int) #creating heatmap, labeling self.heatmapplot = pg.PlotItem() self.heatmapplot.setLabel('bottom', 'Row') self.heatmapplot.setLabel('left', 'Channel') self.heatmapplot.setXRange(0, 8, padding=0) self.heatmapplot.setYRange(0, 32, padding=0) self.heatmap = pg.ImageView(view= self.heatmapplot) self.heatmap.setPredefinedGradient('thermal') self.heatmap.setImage(z) #changes levels for heatmap to create gradient at depending on the data rate if self.frameperfile == 11: self.heatmap.setLevels(60, 260) else: self.heatmap.setLevels(100, 190) self.grid.addWidget(self.heatmap, 3, 2, 2, 5)
def _create_container_and_plots(self, ticks): """ Method that creates the plot container, sets up the event and helper plots, the axes labels and ticks. :param ticks: The ticks to be used on the y axis :return: plot_container: a plot container as `pg.PlotItem` event_plots: a dict that maps event types to the plots in the plot container helper_plots: a dict that maps the helper plot labels to plots in the plot container """ plot_container = pg.PlotItem(title="Events", labels={ 'left': ','.join(self.y_axis_ticks), 'bottom': 'time (us)' }, axisItems={'left': ticks}) # Event plots init event_plots = {} for event_type in self.processed_data.get_event_types(): event_plots[event_type] = plot_container.plot([], []) # For the support lines: one for each track, from 0 to the maximum y # value assigned during the mapping; the length of each line is the # maximum event time xs = [0, self.max_x] * (self.max_y + 1) # For y we must repeat each coord two times so we have a y coord for # both the dest and the source (horizontal line) ys = [y for t in range(0, self.max_y + 1) for y in [t, t]] helper_plots = { 'lines': plot_container.plot(xs, ys, pen=pg.mkPen(255, 255, 255, 32), connect="pairs"), 'highlight': plot_container.plot([], []) } return plot_container, event_plots, helper_plots
def generate_scatter_plot(params_dict, feature1, electrode1, feature2, electrode2): """ This function takes the parameters calculated for the waveforms and generates a scatter plot for selected electrodes and features. Inputs: params_dict: Dictionary containing the waveform parameters as generated by the calculate_params function. feature1: The feature to be plotted on x axis. electrode1: From which electrode the parameter will be pulled for the x axis. feature2: The feature to be plotted on y axis. electrode2: From which electrode the parameter will be pulled for the y axis. Outputs: plt: Scatter plot item containing the scatter plot generated for the selected parameters """ y_label = feature2 + ' on Electrode #' + str(electrode2) x_label = feature1 + ' on Electrode #' + str(electrode1) plt = pg.PlotItem(labels={'left': y_label, 'bottom': x_label}) s = pg.ScatterPlotItem() spots = [] for i in range(n_clusters): feat1_array = params_dict[str(i)][feature1] feat2_array = params_dict[str(i)][feature2] pos = np.column_stack( (feat1_array[:, electrode1], feat2_array[:, electrode2])) for j in range(len(feat1_array)): spots.append({ 'pos': pos[j, :], 'size': 5, 'symbol': 'o', 'pen': pg.mkPen(None), 'brush': pg.intColor(i, n_clusters) }) s.addPoints(spots) plt.addItem(s) return plt
def __init__(self, parent=None): self.parent = parent self.stackStart = 0 self.stackSizeMax = 120 self.stackSize = 20 ## Dock 3: Image Stack self.dock = Dock("Image Scroll", size=(1, 1)) self.winL = pg.LayoutWidget() self.win = pg.ImageView(view=pg.PlotItem()) self.win.getView().invertY(False) self.scroll = np.random.random((5, 10, 10)) self.win.setImage(self.scroll, xvals=np.linspace(0., self.scroll.shape[0] - 1, self.scroll.shape[0])) self.spinBox = QtGui.QSpinBox() self.spinBox.setValue(0) self.label = QtGui.QLabel("Event Number:") self.stackSizeBox = QtGui.QSpinBox() self.stackSizeBox.setMaximum(self.stackSizeMax) self.stackSizeBox.setValue(self.stackSize) self.startBtn = QtGui.QPushButton("&Load image stack") # Connect listeners to functions self.winL.addWidget(self.win, row=0, colspan=4) self.winL.addWidget(self.label, 1, 0) self.winL.addWidget(self.spinBox, 1, 1) self.winL.addWidget(self.stackSizeBox, 1, 2) self.winL.addWidget(self.startBtn, 1, 3) self.dock.addWidget(self.winL) self.threadpool = LaunchStackProducer.StackProducer( self.parent) # send parent parameters if using_pyqt4: self.parent.connect(self.threadpool, QtCore.SIGNAL("finished()"), self.displayImageStack) self.parent.connect(self.startBtn, QtCore.SIGNAL("clicked()"), self.loadStack) else: self.threadpool.finished.connect(self.displayImageStack) self.startBtn.clicked.connect(self.loadStack)
def __init__(self): super().__init__() self.results = None self.classifier_names = [] self.colors = [] self._curve_data = {} box = gui.vBox(self.controlArea, "Plot") tbox = gui.vBox(box, "Target Class") tbox.setFlat(True) self.target_cb = gui.comboBox( tbox, self, "target_index", callback=self._replot, contentsLength=8) cbox = gui.vBox(box, "Classifier") cbox.setFlat(True) self.classifiers_list_box = gui.listBox( box, self, "selected_classifiers", "classifier_names", selectionMode=QListWidget.MultiSelection, callback=self._replot) gui.checkBox(box, self, "display_rug", "Show rug", callback=self._on_display_rug_changed) self.plotview = pg.GraphicsView(background="w") self.plot = pg.PlotItem(enableMenu=False) self.plot.setMouseEnabled(False, False) self.plot.hideButtons() axis = self.plot.getAxis("bottom") axis.setLabel("Predicted Probability") axis = self.plot.getAxis("left") axis.setLabel("Observed Average") self.plot.setRange(xRange=(0.0, 1.0), yRange=(0.0, 1.0), padding=0.05) self.plotview.setCentralItem(self.plot) self.mainArea.layout().addWidget(self.plotview)
def __init__(self, trace_size=80, **kwargs): kwargs['view'] = pg.PlotItem(labels=kwargs.pop('labels', None)) super(CrossSectionImageView, self).__init__(**kwargs) self.view.setAspectLocked(lock=False) self.search_mode = False self.signals_connected = False self.set_histogram(False) histogram_action = QtGui.QAction('Histogram', self) histogram_action.setCheckable(True) histogram_action.triggered.connect(self.set_histogram) self.scene.contextMenu.append(histogram_action) self.ui.histogram.gradient.loadPreset('thermal') try: self.connect_signal() except RuntimeError: warnings.warn( 'Scene not set up, cross section signals not connected') self.y_cross_index = 0 self.x_cross_index = 0 self.h_cross_section_widget = CrosshairPlotWidget() self.h_cross_section_widget.add_cross_hair() self.h_cross_section_widget.search_mode = False self.h_cross_section_widget_data = self.h_cross_section_widget.plot( [0, 0]) self.h_line = pg.InfiniteLine(pos=0, angle=0, movable=False) self.view.addItem(self.h_line, ignoreBounds=False) self.v_cross_section_widget = CrosshairPlotWidget() self.v_cross_section_widget.add_cross_hair() self.v_cross_section_widget.search_mode = False self.v_cross_section_widget_data = self.v_cross_section_widget.plot( [0, 0]) self.v_line = pg.InfiniteLine(pos=0, angle=90, movable=False) self.view.addItem(self.v_line, ignoreBounds=False) self.h_cross_section_widget.crosshair_moved.connect( lambda x, _: self.set_position(x=x)) self.v_cross_section_widget.crosshair_moved.connect( lambda y, _: self.set_position(y=y))
def __init__(self, parent=None, analogsignals=[], spiketrains_on_signals=None, xsize=10., max_point_if_decimate=2000, with_time_seeker=False, **kargs): super(SignalViewer, self).__init__(parent) self.max_point_if_decimate = max_point_if_decimate self.mainlayout = QVBoxLayout() self.setLayout(self.mainlayout) self.viewBox = MyViewBox() self.viewBox.doubleclicked.connect(self.open_configure_dialog) self.graphicsview = pg.GraphicsView() #useOpenGL = True) self.mainlayout.addWidget(self.graphicsview) self.plot = pg.PlotItem(viewBox=self.viewBox) self.plot.hideButtons() self.graphicsview.setCentralItem(self.plot) self.paramGlobal = pg.parametertree.Parameter.create( name='Global options', type='group', children=param_global) # inialize self.clear_all() self.set_analosignals(analogsignals) self.set_xsize(xsize) if with_time_seeker: self.timeseeker = TimeSeeker() self.mainlayout.addWidget(self.timeseeker) self.timeseeker.set_start_stop(*find_best_start_stop( analogsignals=analogsignals)) self.timeseeker.time_changed.connect(self.seek) self.timeseeker.fast_time_changed.connect(self.fast_seek)
def __init__(self, display_panel): super().__init__() self.display_panel = display_panel self.main_window = self.display_panel.main_window # Layout self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.layout = pg.GraphicsLayout() self.layout.layout.setColumnFixedWidth(0, self.main_window.axis_width) # Variables self.axes: Optional[Dict[View, pg.AxisItem]] = {} self.vbs: Optional[Dict[View, pg.ViewBox]] = {} self.main_plot = pg.PlotItem(enableMenu=False) self.main_plot.hideButtons() self.main_plot.hideAxis('left') self.main_plot.hideAxis('bottom') self.main_vb: pg.ViewBox = self.main_plot.getViewBox() self.main_vb.sigXRangeChanged.connect(self.zoomChanged) self.main_vb.setXRange(0, 1) self.main_vb.setYRange(0, 1) self.main_vb.setMouseEnabled(False, False) self.main_plot.setZValue(-sys.maxsize - 1) self.axis_bottom = pg.AxisItem('bottom', parent=self.main_vb) self.axis_bottom.setLabel('time (s)') self.axis_bottom.showLabel( self.main_window.application.config['show_x-axis_label']) # self.axis_bottom.setFixedHeight(self.axis_bottom.height()) self.label = pg.LabelItem(justify='left', color=[255, 255, 255, 0]) # Connections self.maxWidthChanged.connect(self.main_window.checkAxesWidths) self.main_vb.sigResized.connect(self.updateViews) self.main_window.cursorReadoutStatus.connect(self.setCursorReadout) self.proxy = pg.SignalProxy(self.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoved) self.buildLayout() self.setCursorReadout(self.main_window.cursor_readout)
def setup_ui(self): main_frame = pg.ImageView(view=pg.PlotItem()) main_frame.ui.roiBtn.hide() main_frame.ui.menuBtn.hide() main_frame.ui.histogram.hide() main_frame.view.mouseClickEvent = self.my_mouse_click_event colormap = pg.ColorMap([0, 1], color=[[0, 0, 0], [255, 255, 255]]) main_frame.setColorMap(colormap) main_left_button = QPushButton() main_left_button.setToolTip("Previous frame") main_left_button.setIcon(QIcon(get_icon("left1.png"))) main_left_button.setIconSize(QSize(30, 30)) main_left_button.setFlat(True) main_left_button.setStyleSheet("border: 0px") main_sld = QSlider(Qt.Horizontal, self) main_sld.setStyleSheet(self.sld_stylesheet) main_right_button = QPushButton() main_right_button.setToolTip("Next frame") main_right_button.setIcon(QIcon((get_icon("right1.png")))) main_right_button.setIconSize(QSize(30, 30)) main_right_button.setFlat(True) main_right_button.setStyleSheet("border: 0px") sld_layout = QHBoxLayout() sld_layout.addWidget(main_left_button) sld_layout.addWidget(main_sld) sld_layout.addWidget(main_right_button) self.visualize_window_layout = QVBoxLayout() self.visualize_window_layout.addWidget(main_frame) self.visualize_window_layout.addLayout(sld_layout) self.visualize_window_layout.setContentsMargins(1, 1, 1, 1) self.visualize_window.setLayout(self.visualize_window_layout) self.main_frame = main_frame self.main_sld = main_sld self.main_left = main_left_button self.main_right = main_right_button
def __init__(self, plot=None): """ Instantiate a plot as a polar plot Parmeters --------- plot : pyqtgraph plotItem the plot that will be converted to a polar plot, defaults to None if None, then a new PlotItem will be created, accessible as polarPlot.plotItem """ if plot is None: self.plotItem = pg.PlotItem() # create a plot item for the plot else: self.plotItem = plot self.plotItem.setAspectLocked() self.plotItem.hideAxis('bottom') self.plotItem.hideAxis('left') self.gridSet = False self.data = None self.rMax = None
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()
def __init__(self, parent=None, cmap=None): plot_item = pg.PlotItem(enableMouse=False) w = pg.ImageView(view=plot_item) super().__init__(parent=parent, w=w, plot_item=plot_item) w.ui.roiBtn.clicked.connect(self._set_roi_pos) self.grid(False) gradient = self.w.ui.histogram.gradient if cmap is None: cmap = viridis gradient.setColorMap(cmap) for tick in gradient.ticks: tick.hide() gradient.setFixedWidth(300) # disable gradient editing gradient.mouseClickEvent = lambda ev: None self.add_plotting_options() self._pos = None self._scale = None self.invertY = True return
def __init__(self, viewbox, parent, model): # Create dummy vectors self.model = model self.parent = parent self.orientation = self.parent.orientation self.slice_change_function = None self.arrows = [] self.viewbox = viewbox self.def_field = None self.drawn = False self.item = None self.arrow_angle = 50 self.plt = pg.PlotItem() self.plt.hideAxis('left') self.plt.hideAxis('right') self.plt.hideAxis('bottom') self.plt.hideAxis('top') self.vol = None self.arrow_color = "22E300" self.vec_mag_min = 0.0 self.vec_mag_max = 5.0
def createAllPlots(self) -> None: self.plots: Dict[str, Dict[str, pg.PlotWidget]] = {} self.curves: Dict[str, Dict[str, pg.PlotDataItem]] = {} self.attack_curves: Dict[str, Dict[str, List[pg.InfiniteLine]]] = {} for i, node in enumerate(self.nodes): self.plots[node] = {} self.curves[node] = {} self.attack_curves[node] = {} for j, sensor in enumerate(self.sensors[node]): name: str = "%s/%s" % (node, sensor) plot = pg.PlotItem(title=name) plot.enableAutoRange("x", False) plot.enableAutoRange("y", True) curve = plot.plot(name=name, pen=pg.mkPen(self.curveColor, width=3)) if not self.profiling: plot.hide() self.plots[node][sensor] = plot self.curves[node][sensor] = curve self.attack_curves[node][sensor] = [] self.nodeGrids[node].addItem(plot)
def __init__(self, model, callback, colormap=None): super().__init__(view=pg.PlotItem()) self.ui.histogram.hide() self.ui.roiBtn.hide() self.ui.menuBtn.hide() self.view.disableAutoRange() self.view.setMouseEnabled(x=False, y=False) # leave enought space so axes are aligned aligned y_axis = self.getView().getAxis('left') y_axis.setWidth(50) y_axis.setLabel('Frequency', units='Hz') y_axis.enableAutoSIPrefix() self._m = model self.callback = callback self.imageItem.mouseClickEvent = self._click if colormap is not None: self.imageItem.setLookupTable(colormap) # apply the colormap self.old_items = []