nspyre.gui.widgets.line_plot

A wrapper for pyqtgraph PlotWidget.

Module Contents

Classes

LinePlotWidget

Qt widget that generates a pyqtgraph 1D line plot with some reasonable default settings and a variety of added features.

class nspyre.gui.widgets.line_plot.LinePlotWidget(*args, title='', xlabel='', ylabel='', font=nspyre_font, legend=True, plot_colors=None, downsample=True, **kwargs)

Qt widget that generates a pyqtgraph 1D line plot with some reasonable default settings and a variety of added features.

Parameters:
  • args – passed to the QWidget init, like super().__init__(*args, **kwargs)

  • title (str) – Plot title.

  • xlabel (str) – Plot x-axis label.

  • ylabel (str) – Plot y-axis label.

  • font (pyqtgraph.Qt.QtGui.QFont) – Font to use in the plot title, axis labels, etc., although the font type may not be fully honored.

  • legend (bool) – If True, display a figure legend.

  • plot_colors (Optional[Any]) – Colors as a list of RGB tuples in the range 0-1 as used by matplotlib.

  • downsample (bool) – If True, utilize the pyqtgraph ‘auto’ downsampling in the ‘mean’ mode (see PlotItem docs).

  • kwargs – passed to the QWidget init, like super().__init__(*args, **kwargs)

plot_widget

pyqtgraph PlotWidget for displaying the plot.

plot_item()

Return the pyqtgraph PlotItem.

set_title(title)

Set the plot title.

Parameters:

title (str) – The new plot title.

setup()

Subclasses should override this function to perform any setup code before the update() function is called from a new thread.

update()

Subclasses should override this function to update the plot. This function will be called repeatedly from a new thread.

teardown()

Subclasses should override this function to perform any teardown code. The thread calling update() isn’t guaranteed to have exited yet.

add_plot(name, pen=None, symbolBrush=(255, 255, 255, 100), symbolPen=(255, 255, 255, 100), symbol='o', symbolSize=3, **kwargs)

Add a new plot to the PlotWidget. Thread safe.

Parameters:
remove_plot(name)

Remove a plot from the display and delete it’s associated data. Thread safe.

Parameters:

name (str) – Name of the plot.

clear_plots()

Remove all plots and delete their associated data. Thread safe.

hide_plot(name)

Remove a plot from the display, keeping its data. Thread safe.

Parameters:

name (str) – Name of the plot.

show_plot(name)

Display a previously hidden plot. Thread safe.

Parameters:

name (str) – Name of the plot.

set_data(name, xdata, ydata, blocking=True)

Queue up x/y data to update a line plot. Thread safe.

Parameters:
  • name (str) – Name of the plot.

  • xdata (Any) – Array-like of data for the x-axis.

  • ydata (Any) – Array-like of data for the y-axis.

  • blocking (bool) – Whether this method should block until the data has been plotted.