.. highlight:: python :linenothreshold: 6 .. _examples_taurusplot: Plot data with Taurus ===================== This tutorial builds on the example device used in :doc:`first_gui` 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 :class:`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 :class:`taurus_pyqtgraph.TaurusPlot` is also a PyQtGraph plot widget, so you can combine Taurus models with regular PyQtGraph items:: from taurus_pyqtgraph import TaurusPlot import pyqtgraph as pg import numpy panel = TaurusPlot() model = [("sys/taurustest/1/abscissas,sys/taurustest/1/curve")] panel.setModel(model) c1 = pg.PlotDataItem(name="pg item", pen="b", fillLevel=0, brush="c") c1.setData(numpy.linspace(0, 2, 250)) panel.addItem(c1) .. _examples_taurustrend: Plot a trend ------------ Use :class:`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 :ref:`howto-plotting` and :ref:`howto-trends`. For background on the plotting backends used by Taurus, see :ref:`taurusplot_ui`. .. _taurus_pyqtgraph: https://gitlab.com/taurus-org/taurus_pyqtgraph