Plot data with Taurus

This tutorial builds on the example device used in Build your first Taurus GUI in Python and introduces the plotting widgets provided by the taurus_pyqtgraph plugin.

Plot spectrum attributes

To plot two 1D attributes and watch them update online, create a taurus_pyqtgraph.TaurusPlot and assign the models:

from taurus_pyqtgraph import TaurusPlot

panel = TaurusPlot()
model = ["sys/taurustest/1/abscissas", "sys/taurustest/1/curve"]
panel.setModel(model)

Each spectrum is plotted against its element index.

Plot Y values against an X attribute

For a scatter or Y-vs-X plot, provide a tuple containing the X and Y models:

from taurus_pyqtgraph import TaurusPlot

panel = TaurusPlot()
model = [("sys/taurustest/1/abscissas", "sys/taurustest/1/curve")]
panel.setModel(model)

In this case, abscissas provides the X values instead of being plotted as a separate spectrum.

Combine Taurus models with regular PyQtGraph data

A taurus_pyqtgraph.TaurusPlot is also a PyQtGraph plot widget, so you can combine Taurus models with regular PyQtGraph items:

 1from taurus_pyqtgraph import TaurusPlot
 2import pyqtgraph as pg
 3import numpy
 4
 5panel = TaurusPlot()
 6model = [("sys/taurustest/1/abscissas,sys/taurustest/1/curve")]
 7panel.setModel(model)
 8
 9c1 = pg.PlotDataItem(name="pg item", pen="b", fillLevel=0, brush="c")
10c1.setData(numpy.linspace(0, 2, 250))
11panel.addItem(c1)

Plot a trend

Use taurus_pyqtgraph.TaurusTrend when you want to follow how a scalar attribute changes over time:

from taurus.qt.qtgui.plot import TaurusTrend

panel = TaurusTrend()
model = ["sys/taurustest/1/position"]
panel.setModel(model)

If the model is a 1D attribute instead of a scalar, TaurusTrend interprets it as a collection of scalar values and creates a separate trend line for each one.

Next steps

For task-oriented plotting options such as zooming, configuration, exporting, or fixed trend ranges, see Work with TaurusPlot and Work with Taurus trends. For background on the plotting backends used by Taurus, see Plotting with Taurus.