datalogd.plugins.pyqtgraph_datasink module

class datalogd.plugins.pyqtgraph_datasink.PlotWindow(parent=None, data_queue=None, npoints=2048, plotlayout=None, xlink=True, crosshair=True, **kwargs)[source]

Bases: sphinx.ext.autodoc.importer._MockObject

closeEvent(event)[source]
eventFilter(obj, event)[source]
class datalogd.plugins.pyqtgraph_datasink.PyqtgraphDataSink(**kwargs)[source]

Bases: datalogd.DataSink

Plot data in realtime in a pyqtgraph window.

Multiple plot areas may be defined which will be stacked in rows with (by default) linked time axes. Each plot area may itself have multiple traces contained within. The complete plot configuration is defined in the initialisation parameters. The data to use for each trace is selected by matching a series of key-value pairs, in a similar manner to the KeyValDataFilter.

A limited number of data points are stored to be plotted, after which the oldest data points will be discarded to make way for incoming data. The number of data points can be specified with the npoints parameter, with a default of 2048.

The plot layout is described by the plotlayout parameter. As python code:

plotlayout = [
    # List of plot panels
    {
        # Plot 1 panel definition
        'ylabel': 'Value (a.u)',
        'traces': [
            # List of trace definitions for this plot panel
            {
                # Trace 1 definition
                'name': 'Trace 1',
                'pen': [255, 255, 0],
                'selector': [
                    # list of key-value pairs to match to data (same as KeyValDataFilter)
                    ['type', 'analog'],
                    ['id', '.*0']
                ]
            }, # ... possibly more trace definitions
        ]
    }, # ... possibly more plot definitions
]

In the connection graph configuration the plotlayout data structure must be a string formatted as JSON.

Note that any fields present in a trace definition (such as 'name' and 'pen') are passed to the pyqtgraph PlotDataItem initialisation which may be used to customise the trace, such as defining line color or changing to a scatter plot.

Passing the parameter xlink=False will unlink the time axes of the plots, so changes to the view of one plot will not affect the others.

By default, a crosshair will be shown under the mouse pointer. Values for each trace at the crosshair x position are shown in the legend, and the y position of the crosshair will be shown to the right of the plot. To disable this functionality, pass crosshair=False.

Any additional parameters are passed to the pyqtgraph GraphicsLayoutWidget initialisation, which can be used to customise the plot window. For example, changing the window title and size with title="Plots" and size=[1000, 600].

Parameters:
  • npoints – Maximum number of data points for a trace.
  • title – String for title of the plot window.
  • size – Tuple of (height, width) of the plot window.
  • plotlayout – Data structure describing the plot layout and traces.
  • xlink – Boolean, link the time axes of the plots.
  • crosshair – Boolean, show the crosshair under the mouse pointer.
close()[source]

Signal the pyqtgraph application to close when the application is shutting down.

receive(data)[source]

Accept the provided data and pass it to the pyqtgraph PlotWindow for display.