Module audian.rangeplot
Basic PlotItem that can be managed by PlotRange.
Classes
class RangePlot (aspec, channel, browser, *args, **kwargs)
-
GraphicsWidget implementing a standard 2D plotting area with axes.
Bases: :class:
GraphicsWidget <pyqtgraph.GraphicsWidget>
This class provides the ViewBox-plus-axes that appear when using :func:
pg.plot() <pyqtgraph.plot>
, :class:PlotWidget <pyqtgraph.PlotWidget>
, and :func:GraphicsLayout.addPlot() <pyqtgraph.GraphicsLayout.addPlot>
.It's main functionality is:
- Manage placement of ViewBox, AxisItems, and LabelItems
- Create and manage a list of PlotDataItems displayed inside the ViewBox
- Implement a context menu with commonly used display and analysis options
Use :func:
plot() <pyqtgraph.PlotItem.plot>
to create a new PlotDataItem and add it to the view. Use :func:addItem() <pyqtgraph.PlotItem.addItem>
to add any QGraphicsItem to the view.This class wraps several methods from its internal ViewBox: - :func:
setXRange <pyqtgraph.ViewBox.setXRange>
- :func:setYRange <pyqtgraph.ViewBox.setYRange>
- :func:setRange <pyqtgraph.ViewBox.setRange>
- :func:autoRange <pyqtgraph.ViewBox.autoRange>
- :func:setDefaultPadding <pyqtgraph.ViewBox.setDefaultPadding>
- :func:setXLink <pyqtgraph.ViewBox.setXLink>
- :func:setYLink <pyqtgraph.ViewBox.setYLink>
- :func:setAutoPan <pyqtgraph.ViewBox.setAutoPan>
- :func:setAutoVisible <pyqtgraph.ViewBox.setAutoVisible>
- :func:setLimits <pyqtgraph.ViewBox.setLimits>
- :func:viewRect <pyqtgraph.ViewBox.viewRect>
- :func:viewRange <pyqtgraph.ViewBox.viewRange>
- :func:setMouseEnabled <pyqtgraph.ViewBox.setMouseEnabled>
- :func:enableAutoRange <pyqtgraph.ViewBox.enableAutoRange>
- :func:disableAutoRange <pyqtgraph.ViewBox.disableAutoRange>
- :func:setAspectLocked <pyqtgraph.ViewBox.setAspectLocked>
- :func:invertY <pyqtgraph.ViewBox.invertY>
- :func:invertX <pyqtgraph.ViewBox.invertX>
- :func:register <pyqtgraph.ViewBox.register>
- :func:unregister <pyqtgraph.ViewBox.unregister>
The ViewBox itself can be accessed by calling :func:
getViewBox() <pyqtgraph.PlotItem.getViewBox>
==================== ======================================================================= Signals: sigYRangeChanged wrapped from :class:
ViewBox <pyqtgraph.ViewBox>
sigXRangeChanged wrapped from :class:ViewBox <pyqtgraph.ViewBox>
sigRangeChanged wrapped from :class:ViewBox <pyqtgraph.ViewBox>
==================== =======================================================================Create a new PlotItem. All arguments are optional. Any extra keyword arguments are passed to :func:
PlotItem.plot() <pyqtgraph.PlotItem.plot>
.============== ========================================================================================== Arguments: title Title to display at the top of the item. Html is allowed. labels A dictionary specifying the axis labels to display::
{'left': (args), 'bottom': (args), ...} The name of each axis and the corresponding arguments are passed to :func:`PlotItem.setLabel() <pyqtgraph.PlotItem.setLabel>` Optionally, PlotItem my also be initialized with the keyword arguments left, right, top, or bottom to achieve the same effect.
name Registers a name for this view so that others may link to it viewBox If specified, the PlotItem will be constructed with this as its ViewBox. axisItems Optional dictionary instructing the PlotItem to use pre-constructed items for its axes. The dict keys must be axis names ('left', 'bottom', 'right', 'top') and the values must be instances of AxisItem (or at least compatible with AxisItem). ============== ==========================================================================================
Expand source code
class RangePlot(pg.PlotItem): def __init__(self, aspec, channel, browser, *args, **kwargs): self.aspec = aspec self.channel = channel self.data_items = [] # view box: view = SelectViewBox(channel) # plot: pg.PlotItem.__init__(self, viewBox=view, *args, **kwargs) # design: self.getViewBox().setDefaultPadding(padding=0) # functionality: self.hideButtons() self.setMenuEnabled(False) self.enableAutoRange(False, False) self.getViewBox().init_zoom_history() # signals: self.sigRangeChanged.connect(browser.update_ranges) self.getViewBox().sigSelectedRegion.connect(browser.region_menu) # cross hair: self.xline = pg.InfiniteLine(angle=90, movable=False) self.xline.setPen(pg.mkPen('white', width=1)) self.xline.setZValue(100) self.xline.setValue(0) self.xline.setVisible(False) self.addItem(self.xline, ignoreBounds=True) self.yline = pg.InfiniteLine(angle=0, movable=False) self.yline.setPen(pg.mkPen('white', width=1)) self.yline.setZValue(100) self.yline.setValue(0) self.yline.setVisible(False) self.addItem(self.yline, ignoreBounds=True) # stored cross hair marker: self.stored_marker = pg.ScatterPlotItem( size=14, pen=pg.mkPen('white'), brush=pg.mkBrush((255, 255, 255, 128)), symbol='o', hoverable=False ) self.stored_marker.setZValue(20) self.addItem(self.stored_marker, ignoreBounds=True) def x(self): return self.aspec[0] def y(self): return self.aspec[1] def z(self): return self.aspec[2] if len(self.aspec) > 2 else '' def add_item(self, item, is_data=False): if is_data: self.data_items.append(item) item.ax = self self.addItem(item) def range(self, axspec): return None, None, None def amplitudes(self, t0, t1): return None, None def get_marker_pos(self, x0, x1, y): return x0, y, None def set_stored_marker(self, x, y): self.stored_marker.setData((x, ), (y, )) self.stored_marker.setVisible(True) def update_plot(self): for item in self.data_items: if item.isVisible(): item.update_plot()
Ancestors
- pyqtgraph.graphicsItems.PlotItem.PlotItem.PlotItem
- pyqtgraph.graphicsItems.GraphicsWidget.GraphicsWidget
- pyqtgraph.graphicsItems.GraphicsItem.GraphicsItem
- PyQt5.QtWidgets.QGraphicsWidget
- PyQt5.QtWidgets.QGraphicsObject
- PyQt5.QtCore.QObject
- PyQt5.QtWidgets.QGraphicsItem
- PyQt5.QtWidgets.QGraphicsLayoutItem
- sip.wrapper
- sip.simplewrapper
Subclasses
Methods
def x(self)
-
x(self) -> float
def y(self)
-
y(self) -> float
def z(self)
def add_item(self, item, is_data=False)
def range(self, axspec)
def amplitudes(self, t0, t1)
def get_marker_pos(self, x0, x1, y)
def set_stored_marker(self, x, y)
def update_plot(self)