Rapid File Plotting Plotting

I see someone is talking about 'speed' and how 'fast' you can plot.... here's the thing, fast isn't a programming term, scale-ability is, this means you can keep passing more and more and its going to be able to keep displaying at the same speed.

The standard way of animating, is creating a plot with lines then deleting it and re creating the lines. Now that's very inefficient, but it works and is very easy to do.

What you are doing here is you are always recreating the more and more lines it looks like, so you are stacking it up until your computer decides to move memory to your hard drive back and forth.

Here's a good example i found:

from matplotlib import pyplot as plt
from matplotlib import animation

fig = plt.figure()

ax = plt.axes(xlim=(0, 2), ylim=(0, 100))

N = 4 # amount of lines
lines = [plt.plot([], [])[0] for _ in range(N)] # return line object

def init():    
    for line in lines:
        line.set_data([], [])
    return lines

def animate(i):
    # this function is called in the loop, so pull data from here
    for j,line in enumerate(lines):
        line.set_data([0, 2], [10 * j,i]) # then this sets the lines
    return lines # if blit = True it wont change the items who din't change.

anim = animation.FuncAnimation(fig, animate, init_func=init,
                               frames=100, interval=20, blit=True) # the matplotlib animation loop

plt.show()

Now your storage source 'could' be a bottle neck, but i've been storing 200 columns of floating point items with over 10K rows and plotting them, this should not be your issue. Most likely its how you are plotting the line objects.

/r/learnpython Thread