Example #1
0
import numpy
from taurus.qt.qtgui.tpg import Y2ViewBox, CurvesPropertiesTool

if __name__ == "__main__":
    import sys

    app = Qt.QApplication([])

    w = pg.PlotWidget()

    # add Y2 viewbox (provides a ViewBox associated to bottom & right axes)
    y2 = Y2ViewBox()
    y2.attachToPlotItem(w.getPlotItem())

    # add a data item to Y1 (just as you would normally)
    c1 = pg.PlotDataItem(name="c1", pen="c")
    c1.setData(y=numpy.linspace(0, 20, 250))
    w.addItem(c1)

    # add a data item to Y2 (similar, but adding it to the secondary ViewBox!)
    c2 = pg.PlotDataItem(name="c2", pen="y")
    c2.setData(y=numpy.random.rand(250))
    y2.addItem(c2)  # <- note that it is y2, not w !

    # (optional) add CurvesPropertiesTool to switch curves between Y1 and Y2
    t = CurvesPropertiesTool()
    t.attachToPlotItem(w.getPlotItem(), y2=y2)

    w.show()
    sys.exit(app.exec_())
    )

    from taurus.core.taurusmanager import TaurusManager

    taurusM = TaurusManager()
    taurusM.changeDefaultPollingPeriod(1000)  # ms

    app = TaurusApplication()

    # a standard pyqtgraph plot_item
    axis = DateAxisItem(orientation="bottom")
    w = pg.PlotWidget()
    axis.attachToPlotItem(w.getPlotItem())

    cp = CurvesPropertiesTool()
    cp.attachToPlotItem(w.getPlotItem())

    autopan = XAutoPanTool()
    autopan.attachToPlotItem(w.getPlotItem())

    # add legend to the plot, for that we have to give a name to plot items
    w.addLegend()

    # adding a taurus data item...
    c2 = TaurusTrendSet(name="foo")
    c2.setModel("eval:rand(2)")
    # c2.setForcedReadPeriod(500)

    w.addItem(c2)

    # ...and remove it after a while
Example #3
0
    y2ViewBox = Y2ViewBox()
    y2ViewBox.attachToPlotItem(w.getPlotItem())

    # adding a regular data item (non-taurus)
    c1 = pg.PlotDataItem(
        name='st plot',
        pen=dict(color='y', width=3, style=QtCore.Qt.DashLine),
        fillLevel=0.3,
        fillBrush='g'
        )

    c1.setData(numpy.arange(300)/300.)
    w.addItem(c1)

    # adding a taurus data item
    c2 = TaurusPlotDataItem(name='st2 plot',  pen='r', symbol='o',
                            symbolSize=10)
    c2.setModel('sys/tg_test/1/wave')

    w.addItem(c2)

    # attach tool to plot item of the PlotWidget
    tool = CurvesPropertiesTool()
    tool.attachToPlotItem(w.getPlotItem(), y2=y2ViewBox)

    w.show()

    # directly trigger the tool
    tool.trigger ()

    sys.exit(app.exec_())