What is the easiest way to achieve realtime plotting in pyqtgraph

若如初见. 提交于 2019-12-17 15:35:55

问题


I do not get how to achieve realtime plotting in pyqtgraph. The realisation of that is not implemented in the documentation yet.

Could anyone please provide an easy example ?


回答1:


Pyqtgraph only enables realtime plotting by being quick to draw new plot data. How to achieve realtime plotting is highly dependent on the details and control flow in your application.

The most common ways are:

  1. Plot data within a loop that makes calls to QApplication.processEvents().

    pw = pg.plot()
    while True:
        ...
        pw.plot(x, y, clear=True)
        pg.QtGui.QApplication.processEvents()
    
  2. Use a QTimer to make repeated calls to a function that updates the plot.

    pw = pg.plot()
    timer = pg.QtCore.QTimer()
    def update():
        pw.plot(x, y, clear=True)
    timer.timeout.connect(update)
    timer.start(16)
    


来源:https://stackoverflow.com/questions/18080170/what-is-the-easiest-way-to-achieve-realtime-plotting-in-pyqtgraph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!