PlotDataItem

class pyqtgraph.PlotDataItem(*args, **kargs)

Bases: GraphicsObject

GraphicsItem for displaying plot curves, scatter plots, or both. While it is possible to use PlotCurveItem or ScatterPlotItem individually, this class provides a unified interface to both. Inspances of PlotDataItem are usually created by plot() methods such as pyqtgraph.plot() and PlotItem.plot().

Signals:  
sigPlotChanged(self) Emitted when the data in this item is updated.
sigClicked(self) Emitted when the item is clicked.
sigPointsClicked(self, points) Emitted when a plot point is clicked Sends the list of points under the mouse.
__init__(*args, **kargs)

There are many different ways to create a PlotDataItem:

Data initialization arguments: (x,y data only)

PlotDataItem(xValues, yValues) x and y values may be any sequence (including ndarray) of real numbers
PlotDataItem(yValues) y values only – x will be automatically set to range(len(y))
PlotDataItem(x=xValues, y=yValues) x and y given by keyword arguments
PlotDataItem(ndarray(Nx2)) numpy array with shape (N, 2) where x=data[:,0] and y=data[:,1]

Data initialization arguments: (x,y data AND may include spot style)

PlotDataItem(recarray) numpy array with dtype=[(‘x’, float), (‘y’, float), ...]
PlotDataItem(list-of-dicts) [{‘x’: x, ‘y’: y, ...}, ...]
PlotDataItem(dict-of-lists) {‘x’: [...], ‘y’: [...], ...}
PlotDataItem(MetaArray) 1D array of Y values with X sepecified as axis values OR 2D array with a column ‘y’ and extra columns as needed.
Line style keyword arguments:
pen Pen to use for drawing line between points. Default is solid grey, 1px width. Use None to disable line drawing. May be any single argument accepted by mkPen()
shadowPen Pen for secondary line to draw behind the primary line. disabled by default. May be any single argument accepted by mkPen()
fillLevel Fill the area between the curve and fillLevel
fillBrush Fill to use when fillLevel is specified. May be any single argument accepted by mkBrush()

Point style keyword arguments: (see ScatterPlotItem.setData() for more information)

symbol Symbol to use for drawing points OR list of symbols, one per point. Default is no symbol. Options are o, s, t, d, +, or any QPainterPath
symbolPen Outline pen for drawing points OR list of pens, one per point. May be any single argument accepted by mkPen()
symbolBrush Brush for filling points OR list of brushes, one per point. May be any single argument accepted by mkBrush()
symbolSize Diameter of symbols OR list of diameters.
pxMode (bool) If True, then symbolSize is specified in pixels. If False, then symbolSize is specified in data coordinates.

Optimization keyword arguments:

antialias (bool) By default, antialiasing is disabled to improve performance. Note that in some cases (in particluar, when pxMode=True), points will be rendered antialiased even if this is set to False.
identical deprecated
decimate (int) sub-sample data by selecting every nth sample before plotting

Meta-info keyword arguments:

name name of dataset. This would appear in a legend
dataBounds(ax, frac=1.0, orthoRange=None)

Returns the range occupied by the data (along a specific axis) in this item. This method is called by ViewBox when auto-scaling.

Arguments:  
ax (0 or 1) the axis for which to return this item’s data range
frac (float 0.0-1.0) Specifies what fraction of the total data range to return. By default, the entire range is returned. This allows the ViewBox to ignore large spikes in the data when auto-scaling.
orthoRange ([min,max] or None) Specifies that only the data within the given range (orthogonal to ax) should me measured when returning the data range. (For example, a ViewBox might ask what is the y-range of all data with x-values between min and max)
setData(*args, **kargs)

Clear any data displayed by this item and display new data. See __init__() for details; it accepts the same arguments.

setPen(*args, **kargs)
Sets the pen used to draw lines between points.
pen can be a QPen or any argument accepted by pyqtgraph.mkPen()
setShadowPen(*args, **kargs)
Sets the shadow pen used to draw lines between points (this is for enhancing contrast or emphacizing data).
This line is drawn behind the primary pen (see setPen()) and should generally be assigned greater width than the primary pen.
pen can be a QPen or any argument accepted by pyqtgraph.mkPen()

Previous topic

Pyqtgraph’s Graphics Items

Next topic

PlotItem

This Page