PyDMWaveformPlot
- class pydm.widgets.waveformplot.PyDMWaveformPlot(parent=None, init_x_channels=[], init_y_channels=[], background='default')[source]
Bases:
BasePlot
PyDMWaveformPlot is a widget to plot one or more waveforms.
Each curve can plot either a Y-axis waveform vs. its indices, or a Y-axis waveform against an X-axis waveform.
- 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, plot_style=None, name=None, color=None, lineStyle=None, lineWidth=None, symbol=None, symbolSize=None, barWidth=None, upperThreshold=None, lowerThreshold=None, thresholdColor=None, redraw_mode=None, yAxisName=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) –
- WaveformCurveItem.REDRAW_ON_EITHER: (Default)
Redraw after either X or Y receives new data.
- WaveformCurveItem.REDRAW_ON_X:
Redraw after X receives new data.
- WaveformCurveItem.REDRAW_ON_Y:
Redraw after Y receives new data.
- WaveformCurveItem.REDRAW_ON_BOTH:
Redraw after both X and Y receive new data.
symbol (str or None, optional) – Which symbol to use to represent the data.
symbolSize (int, optional) – Size of the symbol.
barWidth (float, optional) – Width of any bars drawn on the plot
upperThreshold (float, optional) – Bars that are above this value will be drawn in the threshold color
lowerThreshold (float, optional) – Bars that are below this value will be drawn in the threshold color
thresholdColor (QColor, optional) – Color to draw bars that exceed either threshold
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.
- curves
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 (WaveformCurveItem) – 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.
WaveformCurveItem
- class pydm.widgets.waveformplot.WaveformCurveItem(y_addr=None, x_addr=None, redraw_mode=None, plot_style='Line', **kws)[source]
Bases:
BasePlotCurveItem
WaveformCurveItem represents a single curve in a waveform plot.
It can be used to plot one waveform vs. its indices, or one waveform vs. another. In addition to the parameters listed below, WaveformCurveItem accepts keyword arguments for all plot options that pyqtgraph.PlotDataItem accepts.
- Parameters:
y_addr (str, optional) – The address to waveform data for the Y axis. Curves must have Y data to plot.
x_addr (str, optional) – The address to waveform data for the X axis. If None, the curve will plot Y data vs. the Y index.
color (QColor, optional) – The color used to draw the curve line and the symbols.
lineStyle (int, optional) – Style of the line connecting the data points. Must be a value from the Qt::PenStyle enum (see http://doc.qt.io/qt-5/qt.html#PenStyle-enum).
lineWidth (int, optional) – Width of the line connecting the data points.
redraw_mode (int, optional) –
Must be one four values:
WaveformCurveItem.REDRAW_ON_EITHER: (Default) Redraw after either X or Y receives new data.
WaveformCurveItem.REDRAW_ON_X: Redraw after X receives new data.
WaveformCurveItem.REDRAW_ON_Y: Redraw after Y receives new data.
WaveformCurveItem.REDRAW_ON_BOTH: Redraw after both X and Y receive new data.
**kargs (optional) – PlotDataItem keyword arguments, such as symbol and symbolSize.
- limits()[source]
Limits of the data for this curve. Returns a nested tuple of limits: ((xmin, xmax), (ymin, ymax))
- Return type:
tuple
- receiveXWaveform(new_waveform)[source]
Handler for new x waveform 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_waveform (numpy.ndarray) – A new array values for the X axis.
- receiveYWaveform(new_waveform)[source]
Handler for new y waveform 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_waveform (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]
Returns an OrderedDict representation with values for all properties needed to recreate this curve.
- Return type:
OrderedDict
- update_waveforms_if_ready()[source]
This is called whenever new waveform data is received for X or Y. Based on the value of the redraw_mode attribute, it decides whether the data_changed signal will be emitted. The data_changed signal is used by the plot that owns this curve to request a redraw.
- property x_address
The address of the channel used to get the x axis waveform data.
- Return type:
str
- property y_address
The address of the channel used to get the y axis waveform data.
- Return type:
str