ScatterPlotItem

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

Displays a set of x/y points. Instances of this class are created automatically as part of PlotDataItem; these rarely need to be instantiated directly.

The size, shape, pen, and fill brush may be set for each point individually or for all points.

Signals:

sigPlotChanged(self)

Emitted when the data being plotted has changed

sigClicked(self, points, ev)

Emitted when points are clicked. Sends a list of all the points under the mouse pointer.

sigHovered(self, points, ev)

Emitted when the item is hovered. Sends a list of all the points under the mouse pointer.

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

Accepts the same arguments as setData()

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

Add new points to the scatter plot. Arguments are the same as setData()

clear()[source]

Remove all spots from the scatter plot

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

Set the brush(es) used to fill the interior of each spot. If a list or array is provided, then the brush for each spot will be set separately. Otherwise, the arguments are passed to pg.mkBrush and used as the default brush for all spots which do not have a brush explicitly set.

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

Ordered Arguments:

  • If there is only one unnamed argument, it will be interpreted like the ‘spots’ argument.

  • If there are two unnamed arguments, they will be interpreted as sequences of x and y values.

Keyword Arguments:

spots

Optional list of dicts. Each dict specifies parameters for a single spot: {‘pos’: (x,y), ‘size’, ‘pen’, ‘brush’, ‘symbol’}. This is just an alternate method of passing in data for the corresponding arguments.

x,*y*

1D arrays of x,y values.

pos

2D structure of x,y pairs (such as Nx2 array or list of tuples)

pxMode

If True, spots are always the same size regardless of scaling, and size is given in px. Otherwise, size is in scene coordinates and the spots scale with the view. To ensure effective caching, QPen and QBrush objects should be reused as much as possible. Default is True

symbol

can be one (or a list) of symbols. For a list of supported symbols, see setSymbol(). QPainterPath is also supported to specify custom symbol shapes. To properly obey the position and size, custom symbols should be centered at (0,0) and width and height of 1.0. Note that it is also possible to ‘install’ custom shapes by setting ScatterPlotItem.Symbols[key] = shape.

pen

The pen (or list of pens) to use for drawing spot outlines.

brush

The brush (or list of brushes) to use for filling spots.

size

The size (or list of sizes) of spots. If pxMode is True, this value is in pixels. Otherwise, it is in the item’s local coordinate system.

data

a list of python objects used to uniquely identify each spot.

hoverable

If True, sigHovered is emitted with a list of hovered points, a tool tip is shown containing information about them, and an optional separate style for them is used. Default is False.

tip

A string-valued function of a spot’s (x, y, data) values. Set to None to prevent a tool tip from being shown.

hoverSymbol

A single symbol to use for hovered spots. Set to None to keep symbol unchanged. Default is None.

hoverSize

A single size to use for hovered spots. Set to -1 to keep size unchanged. Default is -1.

hoverPen

A single pen to use for hovered spots. Set to None to keep pen unchanged. Default is None.

hoverBrush

A single brush to use for hovered spots. Set to None to keep brush unchanged. Default is None.

antialias

Whether to draw symbols with antialiasing. Note that if pxMode is True, symbols are always rendered with antialiasing (since the rendered symbols can be cached, this incurs very little performance cost)

compositionMode

If specified, this sets the composition mode used when drawing the scatter plot (see QPainter::CompositionMode in the Qt documentation).

name

The name of this item. Names are used for automatically generating LegendItem entries and by some exporters.

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

Set the pen(s) used to draw the outline around each spot. If a list or array is provided, then the pen for each spot will be set separately. Otherwise, the arguments are passed to pg.mkPen and used as the default pen for all spots which do not have a pen explicitly set.

setPointsVisible(visible, update=True, dataSet=None, mask=None)[source]

Set whether or not each spot is visible. If a list or array is provided, then the visibility for each spot will be set separately. Otherwise, the argument will be used for all spots.

setSize(size, update=True, dataSet=None, mask=None)[source]

Set the size(s) used to draw each spot. If a list or array is provided, then the size for each spot will be set separately. Otherwise, the argument will be used as the default size for all spots which do not have a size explicitly set.

setSymbol(symbol, update=True, dataSet=None, mask=None)[source]

Set the symbol(s) used to draw each spot. If a list or array is provided, then the symbol for each spot will be set separately. Otherwise, the argument will be used as the default symbol for all spots which do not have a symbol explicitly set.

Supported symbols:

  • ‘o’ circle (default)

  • ‘s’ square

  • ‘t’ triangle

  • ‘d’ diamond

  • ‘+’ plus

  • ‘t1’ triangle pointing upwards

  • ‘t2’ triangle pointing right side

  • ‘t3’ triangle pointing left side

  • ‘p’ pentagon

  • ‘h’ hexagon

  • ‘star’

  • ‘x’ cross

  • ‘arrow_up’

  • ‘arrow_right’

  • ‘arrow_down’

  • ‘arrow_left’

  • ‘crosshair’

  • any QPainterPath to specify custom symbol shapes.