PlotDataItem

class pyqtgraph.PlotDataItem(*args, **kargs)[source]

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. Instances 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)[source]

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:

connect Specifies how / whether vertexes should be connected. See arrayToQPath()
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
fillOutline (bool) If True, an outline surrounding the fillLevel area is drawn.
fillBrush Fill to use when fillLevel is specified. May be any single argument accepted by mkBrush()
stepMode If True, two orthogonal lines are drawn for each sample as steps. This is commonly used when drawing histograms. Note that in this case, len(x) == len(y) + 1 (added in version 0.9.9)

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.
decimate deprecated.
downsample (int) Reduce the number of samples displayed by this value
downsampleMethod ‘subsample’: Downsample by taking the first of N samples. This method is fastest and least accurate. ‘mean’: Downsample by taking the mean of N samples. ‘peak’: Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower.
autoDownsample (bool) If True, resample the data before plotting to avoid plotting multiple line segments per pixel. This can improve performance when viewing very high-density data, but increases the initial overhead and memory usage.
clipToView (bool) If True, only plot data that is visible within the X range of the containing ViewBox. This can improve performance when plotting very large data sets where only a fraction of the data is visible at any time.
identical deprecated

Meta-info keyword arguments:

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

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)
pixelPadding()[source]

Return the size in pixels that this item may draw beyond the values returned by dataBounds(). This method is called by ViewBox when auto-scaling.

setData(*args, **kargs)[source]

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

setDownsampling(ds=None, auto=None, method=None)[source]

Set the downsampling mode of this item. Downsampling reduces the number of samples drawn to increase performance.

Arguments:  
ds (int) Reduce visible plot samples by this factor. To disable, set ds=1.
auto (bool) If True, automatically pick ds based on visible range
mode ‘subsample’: Downsample by taking the first of N samples. This method is fastest and least accurate. ‘mean’: Downsample by taking the mean of N samples. ‘peak’: Downsample by drawing a saw wave that follows the min and max of the original data. This method produces the best visual representation of the data but is slower.
setPen(*args, **kargs)[source]
Sets the pen used to draw lines between points.
pen can be a QPen or any argument accepted by pyqtgraph.mkPen()
setShadowPen(*args, **kargs)[source]
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()