PyDMScatterPlot

class pydm.widgets.scatterplot.PyDMScatterPlot(parent=None, init_x_channels=[], init_y_channels=[], background='default')[source]

Bases: BasePlot

PyDMScatterPlot is a widget to plot one scalar value against another. Multiple scalar pairs can be plotted on the same plot. Each pair has a buffer which stores previous values. All values in the buffer are drawn. The buffer size for each pair is user configurable.

Parameters:
  • parent (optional) – The parent of this widget.

  • init_x_channels (optional) – init_x_channels can be a string with the address for a channel, or a list of strings, each containing an address for a channel. If not specified, y-axis waveforms will be plotted against their indices. If a list is specified for both init_x_channels and init_y_channels, they both must have the same length. If a single x channel was specified, and a list of y channels are specified, all y channels will be plotted against the same x channel.

  • init_y_channels (optional) – init_y_channels can be a string with the address for a channel, or a list of strings, each containing an address for a channel. If a list is specified for both init_x_channels and init_y_channels, they both must have the same length. If a single x channel was specified, and a list of y channels are specified, all y channels will be plotted against the same x channel.

  • background (optional) – The background color for the plot. Accepts any arguments that pyqtgraph.mkColor will accept.

addChannel(y_channel=None, x_channel=None, name=None, color=None, lineStyle=None, lineWidth=None, symbol=None, symbolSize=None, redraw_mode=None, buffer_size=None, yAxisName=None, bufferSizeChannelAddress=None)[source]

Add a new curve to the plot. In addition to the arguments below, all other keyword arguments are passed to the underlying pyqtgraph.PlotDataItem used to draw the curve.

Parameters:
  • y_channel (str) – The address for the y channel for the curve.

  • x_channel (str, optional) – The address for the x channel for the curve.

  • name (str, optional) – A name for this curve. The name will be used in the plot legend.

  • color (str or QColor, optional) – A color for the line of the curve. If not specified, the plot will automatically assign a unique color from a set of default colors.

  • lineStyle (int, optional) – Style of the line connecting the data points. 0 means no line (scatter plot).

  • lineWidth (int, optional) – Width of the line connecting the data points.

  • redraw_mode (int, optional) –

    ScatterPlotCurveItem.REDRAW_ON_EITHER: (Default)

    Redraw after either X or Y receives new data.

    ScatterPlotCurveItem.REDRAW_ON_X:

    Redraw after X receives new data.

    ScatterPlotCurveItem.REDRAW_ON_Y:

    Redraw after Y receives new data.

    ScatterPlotCurveItem.REDRAW_ON_BOTH:

    Redraw after both X and Y receive new data.

  • buffer_size (int, optional) – number of points to keep in the buffer.

  • bufferSizeChannelAddress (str, optional) – The name of a channel that defines the buffer size (int).

  • symbol (int, optional) – Which symbol to use to represent the data.

  • symbol – Size of the symbol.

  • yAxisName (str, optional) – The name of the y axis to associate with this curve. Will be created if it doesn’t yet exist

autoRangeX

Whether or not the X-axis automatically rescales to fit the data. If true, the values in minXRange and maxXRange are ignored.

autoRangeY

Whether or not the Y-axis automatically rescales to fit the data. If true, the values in minYRange and maxYRange are ignored.

channels()[source]

Returns the list of channels used by all curves in the plot.

Return type:

list

clearCurves()[source]

Remove all curves from the plot.

curves

Get a list of json representations for each curve.

getCurves()[source]

Get a list of json representations for each curve.

maxXRange

Maximum X-axis value visible on the plot.

maxYRange

Maximum Y-axis value visible on the plot.

minXRange

Minimum X-axis value visible on the plot.

minYRange

Minimum Y-axis value visible on the plot.

redrawPlot()[source]

Request a redraw from each curve in the plot. Called by curves when they get new data.

removeChannel(curve)[source]

Remove a curve from the plot.

Parameters:

curve (ScatterPlotCurveItem) – The curve to remove.

removeChannelAtIndex(index)[source]

Remove a curve from the plot, given an index for a curve.

Parameters:

index (int) – Index for the curve to remove.

setCurves(new_list)[source]

Replace all existing curves with new ones. This function is mostly used as a way to load curves from a .ui file, and almost all users will want to add curves through addChannel, not this method.

Parameters:

new_list (list) – A list of json strings representing each curve in the plot.

ScatterPlotCurveItem

class pydm.widgets.scatterplot.ScatterPlotCurveItem(y_addr, x_addr, redraw_mode=None, bufferSizeChannelAddress=None, **kws)[source]

Bases: BasePlotCurveItem

property bufferSizeChannelAddress

The address of the channel used to get the buffer size.

Returns:

The address of the channel used to get the buffer size.

Return type:

str

bufferSizeChannelValueReceiver(value)[source]

Handler for change in buffer size. This method is usually called by a PyDMChannel when it updates. You can call this yourself to set or change the buffer size.

Parameters:

value (int) – A new value for the buffer size.

limits()[source]

Get the limits of the data for this curve.

Returns:

A nested tuple of limits: ((xmin, xmax), (ymin, ymax))

Return type:

tuple

receiveXValue(new_x)[source]

Handler for new x data. This method is usually called by a PyDMChannel when it updates. You can call this yourself to inject data into the curve.

Parameters:

new_x (numpy.ndarray) – A new array values for the X axis.

receiveYValue(new_y)[source]

Handler for new y data. This method is usually called by a PyDMChannel when it updates. You can call this yourself to inject data into the curve.

Parameters:

new_y (numpy.ndarray) – A new array values for the Y axis.

redrawCurve()[source]

Called by the curve’s parent plot whenever the curve needs to be re-drawn with new data.

to_dict()[source]

Serialize this curve into a dictionary.

Returns:

Representation with values for all properties needed to recreate this curve.

Return type:

OrderedDict

update_buffer()[source]

This is called whenever new data is received for X or Y. Based on the value of the redraw_mode attribute, it decides whether we are ready to shift the data buffer by one and add the latest data.

property x_address

The address of the channel used to get the x axis data.

Returns:

The address of the channel used to get the x axis data.

Return type:

str

property y_address

The address of the channel used to get the y axis data.

Returns:

The address of the channel used to get the y axis data.

Return type:

str