'Most lightweight way to plot streaming data in python

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 done in postprocessing).

I'm wondering if there is a lighter weight way to plot other than shifting my data to the left and redrawing the entire plot.



Solution 1:[1]

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)

Solution 2:[2]

You could try streamlit lib. Should be the lightest one.

Solution 3:[3]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Thorsten Kranz
Solution 2 adiya dalat
Solution 3 Vorac