On Sat, May 16, 2009 at 6:57 AM, amrbekhit <amrbek...@gmail.com> wrote: > > Hello, > > I am trying to write an application that measures data from an external > device and then displays the data on a graph, updating the graph when new > measurements arrive. Searching the web has led to matplotlib and so I've > been having a go at using that for my program. After searching around on the > forums, I have had some success in implementing the functionality I am > aiming for, but the application gets very very slow the longer it runs.
By default matplotlib overplots, meaning it keeps the old data around in addition to the new data, so you are plotting on the i-th iteration 0: [d0] 1: [d0], [d0, d1][d0], [d0, d1] 2: [d0], [d0, d1], [d0, d1, d2], .... You probably don't see it because the new points overlap the old. If you turn overplotting off ax.hold(False) before issuing the plot commands you should not see the dramatic slowing. You can speed up the performance further by reusing the same line object, eg somelimit = 1000 line, = ax.plot([], []) xs = [] ys = [] for row in mydata: xs.append(row['newx']) ys.append(row['newy']) if len(xs)>somelimit: del xs[0] del ys[0] line.set_data(xs, ys) ax.figure.canvas.draw() See also the animation tutorial and examples http://www.scipy.org/Cookbook/Matplotlib/Animations http://matplotlib.sourceforge.net/examples/animation/index.html JDH ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users