在pyqtgraph中实现实时绘图的最简单方法是什么 [英] What is the easiest way to achieve realtime plotting in pyqtgraph

查看:39
本文介绍了在pyqtgraph中实现实时绘图的最简单方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何在 pyqtgraph 中实现实时绘图.文档中尚未实现该实现.

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 ?

推荐答案

Pyqtgraph 仅通过快速绘制新的绘图数据启用实时绘图.如何实现实时绘图高度依赖于应用程序中的细节和控制流.

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.

最常见的方式是:

  1. 在调用 QApplication.processEvents() 的循环中绘制数据.

  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()

  • 使用 QTimer 重复调用更新绘图的函数.

  • 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)
    

  • 这篇关于在pyqtgraph中实现实时绘图的最简单方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆