首页 > 解决方案 > 如何每秒更新python中的图表

问题描述

我正在尝试使用 matplotlib.animation 每秒更新一次时间序列数据。这将用于从多个通道获取数据。但是,当我在 update() 函数中使用动画时,没有达到间隔时间(函数循环更快)。请帮助我澄清如何以更适当的方式调用更新函数。谢谢。

标签: pythonchartslive

解决方案


试试看:

from datetime import time
second = datetime.now().strftime("%S")
while True:
    do some things your code should do (no time.sleep in there)
    second_before = datetime.now().strftime("%S")
    if second != second_before:
        second = second_before
        call the function

推荐阅读