Python pyqtgraph.PlotItem() Examples
The following are 28
code examples of pyqtgraph.PlotItem().
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: test_GraphicsItem.py From tf-pose with Apache License 2.0 | 6 votes |
def test_getViewWidget_deleted(): view = pg.PlotWidget() item = pg.InfiniteLine() view.addItem(item) assert item.getViewWidget() is view # Arrange to have Qt automatically delete the view widget obj = pg.QtGui.QWidget() view.setParent(obj) del obj gc.collect() assert not pg.Qt.isQObjectAlive(view) assert item.getViewWidget() is None #if __name__ == '__main__': #view = pg.PlotItem() #vref = weakref.ref(view) #item = pg.InfiniteLine() #view.addItem(item) #del view #gc.collect()
Example #2
Source File: test_GraphicsItem.py From soapy with GNU General Public License v3.0 | 6 votes |
def test_getViewWidget_deleted(): view = pg.PlotWidget() item = pg.InfiniteLine() view.addItem(item) assert item.getViewWidget() is view # Arrange to have Qt automatically delete the view widget obj = pg.QtGui.QWidget() view.setParent(obj) del obj gc.collect() assert not pg.Qt.isQObjectAlive(view) assert item.getViewWidget() is None #if __name__ == '__main__': #view = pg.PlotItem() #vref = weakref.ref(view) #item = pg.InfiniteLine() #view.addItem(item) #del view #gc.collect()
Example #3
Source File: __init__.py From finplot with MIT License | 6 votes |
def _overlay(ax, scale=0.25): global overlay_axs viewbox = FinViewBox(ax.vb.win, init_steps=ax.vb.init_steps, yscale=YScale('linear', 1)) viewbox.v_zoom_scale = scale ax.vb.win.centralWidget.scene().addItem(viewbox) viewbox.setXLink(ax.vb) def updateView(): viewbox.setGeometry(ax.vb.sceneBoundingRect()) axo = pg.PlotItem() axo.significant_decimals = significant_decimals axo.significant_eps = significant_eps axo.vb = viewbox axo.hideAxis('left') axo.hideAxis('bottom') axo.hideButtons() viewbox.addItem(axo) ax.vb.sigResized.connect(updateView) overlay_axs.append(axo) return axo
Example #4
Source File: __init__.py From finplot with MIT License | 6 votes |
def _add_timestamp_plot(win, prev_ax, viewbox, index, yscale): if prev_ax is not None: prev_ax.hideAxis('bottom') # hide the whole previous axis win.nextRow() axes = {'bottom': EpochAxisItem(vb=viewbox, orientation='bottom'), 'left': YAxisItem(vb=viewbox, orientation='left')} ax = pg.PlotItem(viewBox=viewbox, axisItems=axes, name='plot-%i'%index) ax.axes['left']['item'].textWidth = y_label_width # this is to put all graphs on equal footing when texts vary from 0.4 to 2000000 ax.axes['left']['item'].setStyle(tickLength=-5) # some bug, totally unexplicable (why setting the default value again would fix repaint width as axis scale down) ax.axes['left']['item'].setZValue(30) # put axis in front instead of behind data ax.axes['bottom']['item'].setZValue(30) ax.setLogMode(y=(yscale.scaletype=='log')) ax.significant_decimals = significant_decimals ax.significant_eps = significant_eps ax.crosshair = FinCrossHair(ax, color=cross_hair_color) ax.hideButtons() ax.overlay = partial(_overlay, ax) if index%2: viewbox.setBackgroundColor(odd_plot_background) viewbox.setParent(ax) win.addItem(ax) return ax
Example #5
Source File: graphtab.py From equant with GNU General Public License v2.0 | 6 votes |
def makePI(self, name): """生成PlotItem对象""" vb = CustomViewBox(self) plotItem = pg.PlotItem(viewBox=vb, name=name, axisItems={'bottom': self.axisTime}) plotItem.setMenuEnabled(False) # 仅绘制ViewBox可见范围内的点 plotItem.setClipToView(True) plotItem.showAxis('left') # 设置采样模式 plotItem.setDownsampling(mode='peak') plotItem.setRange(xRange=(0, 1), yRange=(0, 1)) plotItem.getAxis('left').setWidth(70) plotItem.getAxis('left').setStyle(tickFont=QtGui.QFont('Roman times', 10, QtGui.QFont.Bold)) plotItem.getAxis('left').setPen(color=(255, 255, 255, 255), width=0.8) plotItem.showGrid(True, True) plotItem.hideButtons() return plotItem
Example #6
Source File: fundtab.py From equant with GNU General Public License v2.0 | 6 votes |
def makePI(self, name): """生成PlotItem对象""" vb = CustomViewBox(self) plotItem = pg.PlotItem(viewBox=vb, name=name, axisItems={'bottom': self.axisTime}) plotItem.setMenuEnabled(False) # 仅绘制ViewBox可见范围内的点 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(70) plotItem.getAxis('right').setStyle(tickFont=QtGui.QFont('Roman times', 10, QtGui.QFont.Bold)) plotItem.getAxis('right').setPen(color=(255, 255, 255, 255), width=0.8) plotItem.showGrid(True, True) plotItem.hideButtons() return plotItem
Example #7
Source File: candle_demo.py From Python-CTPAPI with MIT License | 6 votes |
def __init__(self, parent: QtWidgets.QWidget = None): """""" super().__init__(parent) self._manager: BarManager = BarManager() self._plots: Dict[str, pg.PlotItem] = {} self._items: Dict[str, ChartItem] = {} self._item_plot_map: Dict[ChartItem, pg.PlotItem] = {} self._first_plot: pg.PlotItem = None self._cursor: ChartCursor = None self._right_ix: int = 0 # Index of most right data self._bar_count: int = self.MIN_BAR_COUNT # Total bar visible in chart self._init_ui()
Example #8
Source File: guiContainer.py From wavePicker with GNU General Public License v2.0 | 6 votes |
def initPlot(self): ''' Inits the plot canvas pyqtgraph.plotItem ''' if not self.visible: return self.plotItem = pg.PlotItem(name='%s.%s' % (self.stats.network, self.stats.station), clipToView=True, autoDownsample=True) self.plotItem.hideButtons() self.plotItem.setMouseEnabled(x=True, y=False) self.plotItem.getAxis('left').setWidth(35) self.plotItem.getAxis('bottom').setGrid(150) self.plotItem.enableAutoRange('y', 1.) self.plotItem.getAxis('bottom').setStyle(showValues=False) self.plotSelectedChannel() self.parent.GraphicsLayout.addItem(self.plotItem, row=self.parent.stations.index(self)) self.parent.GraphicsLayout.nextRow() self.parent.updateAllPlots()
Example #9
Source File: uiKLine.py From uiKLine with MIT License | 6 votes |
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 #----------------------------------------------------------------------
Example #10
Source File: uiKLine.py From uiKLine with MIT License | 6 votes |
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(30) plotItem.getAxis('right').setStyle(tickFont = QFont("Roman times",10,QFont.Bold)) plotItem.getAxis('right').setPen(color=(255, 0, 0, 255), width=0.8) plotItem.showGrid(True,True) plotItem.hideButtons() return plotItem #----------------------------------------------------------------------
Example #11
Source File: uiKLine.py From vnpy_crypto with MIT License | 6 votes |
def create_plot_item(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 = QtGui.QFont("Roman times",10,QtGui.QFont.Bold)) plotItem.getAxis('right').setPen(color=(255, 255, 255, 255), width=0.8) plotItem.showGrid(True, True) plotItem.hideButtons() return plotItem # ----------------------------------------------------------------------
Example #12
Source File: uiKLine.py From vnpy_crypto with MIT License | 6 votes |
def init_plot_main(self): """ 初始化主图 1、添加 K线(蜡烛图) :return: """ # 创建K线PlotItem self.pi_main = self.create_plot_item('_'.join([self.windowId, 'Plot_Main'])) # 创建蜡烛图 self.ci_candle = CandlestickItem(self.listBar) # 添加蜡烛图到主图 self.pi_main.addItem(self.ci_candle) self.pi_main.setMinimumHeight(200) self.pi_main.setXLink('_'.join([self.windowId, 'Plot_Sub'])) self.pi_main.hideAxis('bottom') # 添加主图到window layout self.lay_KL.nextRow() self.lay_KL.addItem(self.pi_main) # ----------------------------------------------------------------------
Example #13
Source File: onlinewaveformhistviewer.py From tridesclous with MIT License | 6 votes |
def initialize_plot(self): self.viewBox = MyViewBox() self.viewBox.doubleclicked.connect(self.open_settings) self.viewBox.gain_zoom.connect(self.gain_zoom) self.viewBox.disableAutoRange() self.plot = pg.PlotItem(viewBox=self.viewBox) self.graphicsview.setCentralItem(self.plot) self.plot.hideButtons() self.image = pg.ImageItem() self.plot.addItem(self.image) self.curve_spike = pg.PlotCurveItem() self.plot.addItem(self.curve_spike) self.curve_limit = pg.PlotCurveItem() self.plot.addItem(self.curve_limit) self.change_lut()
Example #14
Source File: candle_demo.py From Python-CTPAPI with MIT License | 5 votes |
def get_plot(self, plot_name: str) -> pg.PlotItem: """ Get specific plot with its name. """ return self._plots.get(plot_name, None)
Example #15
Source File: ReceiveAndPlot.py From liblsl-Python with MIT License | 5 votes |
def __init__(self, info: pylsl.StreamInfo, plt: pg.PlotItem): super().__init__(info) # calculate the size for our buffer, i.e. two times the displayed data bufsize = (2 * math.ceil(info.nominal_srate() * plot_duration), info.channel_count()) self.buffer = np.empty(bufsize, dtype=self.dtypes[info.channel_format()]) empty = np.array([]) # create one curve object for each channel/line that will handle displaying the data self.curves = [pg.PlotCurveItem(x=empty, y=empty, autoDownsample=True) for _ in range(self.channel_count)] for curve in self.curves: plt.addItem(curve)
Example #16
Source File: ReceiveAndPlot.py From liblsl-Python with MIT License | 5 votes |
def pull_and_plot(self, plot_time: float, plt: pg.PlotItem): """Pull data from the inlet and add it to the plot. :param plot_time: lowest timestamp that's still visible in the plot :param plt: the plot the data should be shown on """ # We don't know what to do with a generic inlet, so we skip it. pass
Example #17
Source File: qt_plot_area.py From enamlx with MIT License | 5 votes |
def create_widget(self): if isinstance(self.parent(),AbstractQtPlotItem): self.widget = self.parent_widget() self.is_root = False else: self.is_root = True self.widget = pg.PlotItem()
Example #18
Source File: candle_demo.py From Python-CTPAPI with MIT License | 5 votes |
def get_all_plots(self) -> List[pg.PlotItem]: """ Get all plot objects. """ return self._plots.values()
Example #19
Source File: isiviewer.py From tridesclous with MIT License | 5 votes |
def initialize_plot(self): self.viewBox = MyViewBox() self.viewBox.doubleclicked.connect(self.open_settings) #~ self.viewBox.disableAutoRange() self.plot = pg.PlotItem(viewBox=self.viewBox) self.graphicsview.setCentralItem(self.plot) self.plot.hideButtons() #ISI are computed on demand self.all_isi = {}
Example #20
Source File: featuretimeviewer.py From tridesclous with MIT License | 5 votes |
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()
Example #21
Source File: pgctis.py From argos with GNU General Public License v3.0 | 5 votes |
def __init__(self, plotItem, nodeName="grid", defaultData=True, expanded=False): """ Constructor. The target axis is specified by viewBox and axisNumber (0 for x-axis, 1 for y-axis) """ super(PgGridCti, self).__init__(nodeName, defaultData=defaultData, expanded=expanded) check_class(plotItem, pg.PlotItem) self.plotItem = plotItem self.xGridCti = self.insertChild(BoolCti('x-axis', defaultData)) self.yGridCti = self.insertChild(BoolCti('y-axis', defaultData)) self.alphaCti = self.insertChild(FloatCti('alpha', 0.20, minValue=0.0, maxValue=1.0, stepSize=0.01, decimals=2))
Example #22
Source File: probegeometryview.py From tridesclous with MIT License | 5 votes |
def __init__(self, parent = None, channel_groups=None): QT.QWidget.__init__(self, parent) self.channel_groups = channel_groups self.layout = QT.QVBoxLayout() self.setLayout(self.layout) h = QT.QHBoxLayout() self.layout.addLayout(h) self.combo_chan_grp = QT.QComboBox() h.addWidget(self.combo_chan_grp) self.combo_chan_grp.clear() self.combo_chan_grp.addItems([str(k) for k in self.channel_groups.keys()]) self.combo_chan_grp.currentIndexChanged .connect(self.on_chan_grp_change) self.checkbox = QT.QCheckBox('flip_bottom_up') h.addWidget(self.checkbox) self.checkbox.stateChanged.connect(self.refresh) #~ self.combo_chan_grp.blockSignals(True) #~ self.combo_chan_grp.blockSignals(False) #~ self.on_chan_grp_change() self.graphicsview = pg.GraphicsView() self.layout.addWidget(self.graphicsview) self.viewBox = MyViewBox() self.viewBox.disableAutoRange() self.plot = pg.PlotItem(viewBox=self.viewBox) self.graphicsview.setCentralItem(self.plot) self.plot.hideButtons() self.plot.showAxis('left', False) self.refresh()
Example #23
Source File: silhouette.py From tridesclous with MIT License | 5 votes |
def initialize_plot(self): self.viewBox = MyViewBox() self.viewBox.doubleclicked.connect(self.open_settings) self.viewBox.disableAutoRange() self.plot = pg.PlotItem(viewBox=self.viewBox) self.graphicsview.setCentralItem(self.plot) self.plot.hideButtons()
Example #24
Source File: candle_demo.py From Python-CTPAPI with MIT License | 4 votes |
def add_plot( self, plot_name: str, minimum_height: int = 80, maximum_height: int = None, hide_x_axis: bool = False ) -> None: """ Add plot area. """ # Create plot object plot = pg.PlotItem(axisItems={'bottom': self._x_axis}) plot.setMenuEnabled(False) plot.setClipToView(True) plot.hideAxis('left') plot.showAxis('right') plot.setDownsampling(mode='peak') plot.setRange(xRange=(0, 1), yRange=(0, 1)) plot.hideButtons() plot.setMinimumHeight(minimum_height) if maximum_height: plot.setMaximumHeight(maximum_height) if hide_x_axis: plot.hideAxis("bottom") if not self._first_plot: self._first_plot = plot # Connect view change signal to update y range function view = plot.getViewBox() view.sigXRangeChanged.connect(self._update_y_range) view.setMouseEnabled(x=True, y=False) # Set right axis right_axis = plot.getAxis('right') right_axis.setWidth(60) right_axis.tickFont = NORMAL_FONT # Connect x-axis link if self._plots: first_plot = list(self._plots.values())[0] plot.setXLink(first_plot) # Store plot object in dict self._plots[plot_name] = plot
Example #25
Source File: multiplot.py From kite with GNU General Public License v3.0 | 4 votes |
def __init__(self, sandbox, component, title='Untitled'): pg.PlotItem.__init__(self) self.title = title self.sandbox = sandbox self.component = component self.cursor = CursorRect() self.addCursor() self.setAspectLocked(True) self.setLabels( bottom=('Easting', 'm'), left=('Northing', 'm')) border_pen = pg.mkPen(255, 255, 255, 50) self.image = pg.ImageItem( None, autoDownsample=False, border_pen=border_pen, useOpenGL=True) self.addItem(self.image) self.title_label = pg.LabelItem( text='<span style="color: #9E9E9E;">' '%s</span>' % self.title, justify='right', size='10pt', parent=self) self.title_label.anchor( itemPos=(0., 0.), parentPos=(.01, .01)) self.title_label.setOpacity(.6) self.hint_text = None self.sandbox.sigModelUpdated.connect( self.update) self.sandbox.sources.modelAboutToBeReset.connect( self.removeSourceROIS) self.sandbox.sources.modelReset.connect( self.addSourceROIS) self.update() self.rois = [] self.addSourceROIS()
Example #26
Source File: gui2p.py From suite2p with GNU General Public License v3.0 | 4 votes |
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 #27
Source File: traceviewer.py From tridesclous with MIT License | 4 votes |
def initialize_plot(self): self.viewBox = MyViewBox() self.plot = pg.PlotItem(viewBox=self.viewBox) self.graphicsview.setCentralItem(self.plot) self.plot.hideButtons() self.plot.showAxis('left', False) self.viewBox.gain_zoom.connect(self.gain_zoom) self.viewBox.xsize_zoom.connect(self.xsize_zoom) self.visible_channels = np.zeros(self.controller.nb_channel, dtype='bool') self.max_channel = min(16, self.controller.nb_channel) #~ self.max_channel = min(5, self.controller.nb_channel) if self.controller.nb_channel>self.max_channel: self.visible_channels[:self.max_channel] = True self.scroll_chan.show() self.scroll_chan.setMinimum(0) self.scroll_chan.setMaximum(self.controller.nb_channel-self.max_channel) self.scroll_chan.setPageStep(self.max_channel) else: self.visible_channels[:] = True self.scroll_chan.hide() self.signals_curve = pg.PlotCurveItem(pen='#7FFF00', connect='finite') self.plot.addItem(self.signals_curve) self.scatter = pg.ScatterPlotItem(size=10, pxMode = True) self.plot.addItem(self.scatter) self.scatter.sigClicked.connect(self.scatter_item_clicked) self.channel_labels = [] self.threshold_lines =[] for i, chan_name in enumerate(self.controller.channel_names): #TODO label channels label = pg.TextItem('{}: {}'.format(i, chan_name), color='#FFFFFF', anchor=(0, 0.5), border=None, fill=pg.mkColor((128,128,128, 180))) self.plot.addItem(label) self.channel_labels.append(label) for i in range(self.max_channel): tc = pg.InfiniteLine(angle = 0., movable = False, pen = pg.mkPen(color=(128,128,128, 120))) tc.setPos(0.) self.threshold_lines.append(tc) self.plot.addItem(tc) tc.hide() pen = pg.mkPen(color=(128,0,128, 120), width=3, style=QT.Qt.DashLine) self.selection_line = pg.InfiniteLine(pos = 0., angle=90, movable=False, pen = pen) self.plot.addItem(self.selection_line) self.selection_line.hide() self._initialize_plot() self.gains = None self.offsets = None
Example #28
Source File: crosscorrelogramviewer.py From tridesclous with MIT License | 4 votes |
def refresh(self): self.grid.clear() if self.ccg is None: return visibles = [ ] for k in self.controller.positive_cluster_labels: if self.controller.cluster_visible[k]: visibles.append(k) visibles = visibles[:self.params['max_visible']] n = len(visibles) bins = self.bins * 1000. #to ms labels = self.controller.positive_cluster_labels.tolist() for r in range(n): for c in range(r, n): i = labels.index(visibles[r]) j = labels.index(visibles[c]) count = self.ccg[i, j, :] plot = pg.PlotItem() if not self.params['display_axis']: plot.hideAxis('bottom') plot.hideAxis('left') if r==c: k = visibles[r] color = self.controller.qcolors[k] else: color = (120,120,120,120) curve = pg.PlotCurveItem(bins, count, stepMode=True, fillLevel=0, brush=color, pen=color) plot.addItem(curve) self.grid.addItem(plot, row=r, col=c) #~ plt1.plot(x, y, stepMode=True, fillLevel=0, brush=(0,0,255,150))