Most lightweight way to plot streaming data in python

前端 未结 2 1281
旧时难觅i
旧时难觅i 2021-02-20 17:24

To give you a sense of what I\'m looking for, it looks like this:

Up until now I have used matplotlib for all my plotting, and timing hasn\'t been critical (it\'s been d

相关标签:
2条回答
  • 2021-02-20 17:58

    Have a look at the Matplotlib Animations Examples. The main trick is to not completely redraw the graph but rather use the OO interface of matplotlib and set the x/ydata of the plot-line you created. If you've integrated your plot with some GUI, e.g., GTK, then definitely do it like proposed in the respective section of the plot, otherwise you might interfere with the event-loop of your GUI toolkit.

    For reference, if the link ever dies:

    from pylab import *
    import time
    
    ion()
    
    tstart = time.time()               # for profiling
    x = arange(0,2*pi,0.01)            # x-array
    line, = plot(x,sin(x))
    for i in arange(1,200):
        line.set_ydata(sin(x+i/10.0))  # update the data
        draw()                         # redraw the canvas
    
    print 'FPS:' , 200/(time.time()-tstart)
    
    0 讨论(0)
  • 2021-02-20 18:13

    In the python wiki there is a list of suggestions with short descriptions: link.

    0 讨论(0)
提交回复
热议问题