PlotCurveItem

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

Class representing a single plot curve. Instances of this class are created automatically as part of PlotDataItem; these rarely need to be instantiated directly.

Features:

  • Fast data update

  • Fill under curve

  • Mouse interaction

Signals:

sigPlotChanged(self)

Emitted when the data being plotted has changed

sigClicked(self, ev)

Emitted when the curve is clicked

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

Forwards all arguments to setData.

Some extra arguments are accepted as well:

Arguments:

parent

The parent GraphicsObject (optional)

clickable

If True, the item will emit sigClicked when it is clicked on. Defaults to False.

mouseShape()[source]

Return a QPainterPath representing the clickable shape of the curve

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

Set the brush used when filling the area under the curve

setClickable(s, width=None)[source]

Sets whether the item responds to mouse clicks.

The width argument specifies the width in pixels orthogonal to the curve that will respond to a mouse click.

setCompositionMode(mode)[source]

Change the composition mode of the item. This is useful when overlaying multiple items.

Parameters

mode (QtGui.QPainter.CompositionMode) –

Composition of the item, often used when overlaying items. Common options include:

QPainter.CompositionMode.CompositionMode_SourceOver (Default) Image replaces the background if it is opaque. Otherwise, it uses the alpha channel to blend the image with the background.

QPainter.CompositionMode.CompositionMode_Overlay Image color is mixed with the background color to reflect the lightness or darkness of the background

QPainter.CompositionMode.CompositionMode_Plus Both the alpha and color of the image and background pixels are added together.

QPainter.CompositionMode.CompositionMode_Plus The output is the image color multiplied by the background.

See QPainter::CompositionMode in the Qt Documentation for more options and details

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

Arguments:

x, y

(numpy arrays) Data to show

pen

Pen to use when drawing. Any single argument accepted by mkPen is allowed.

shadowPen

Pen for drawing behind the primary pen. Usually this is used to emphasize the curve by providing a high-contrast border. Any single argument accepted by mkPen is allowed.

fillLevel

(float or None) Fill the area ‘under’ the curve to fillLevel

fillOutline

(bool) If True, an outline surrounding the fillLevel area is drawn.

brush

QBrush to use when filling. Any single argument accepted by mkBrush is allowed.

antialias

(bool) Whether to use antialiasing when drawing. This is disabled by default because it decreases performance.

stepMode

(str or None) If “center”, a step is drawn using the x values as boundaries and the given y values are associated to the mid-points between the boundaries of each step. This is commonly used when drawing histograms. Note that in this case, len(x) == len(y) + 1 If “left” or “right”, the step is drawn assuming that the y value is associated to the left or right boundary, respectively. In this case len(x) == len(y) If not passed or an empty string or None is passed, the step mode is not enabled. Passing True is a deprecated equivalent to “center”.

connect

Argument specifying how vertexes should be connected by line segments. Default is “all”, indicating full connection. “pairs” causes only even-numbered segments to be drawn. “finite” causes segments to be omitted if they are attached to nan or inf values. For any other connectivity, specify an array of boolean values.

compositionMode

See setCompositionMode.

skipFiniteCheck

Optimization parameter that can speed up plot time by telling the painter to not check and compensate for NaN values. If set to True, and NaN values exist, the data may not be displayed or your plot will take a significant performance hit. Defaults to False.

If non-keyword arguments are used, they will be interpreted as setData(y) for a single argument and setData(x, y) for two arguments.

setFillLevel(level)[source]

Set the level filled to when filling under the curve

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

Set the pen used to draw the curve.

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

Set the shadow pen used to draw behind the primary pen. This pen must have a larger width than the primary pen to be visible.