On 05/28/2010 09:18 AM, Pearu Peterson wrote:
> , say, every second and the experiment
> can last hours, I have tried two approaches:
> 1) clear axes and plot new experimental data - this is
> slow and takes too much cpu resources.
> 2) remove lines and plot new experimental data - this is
> fast enough but unfortunately there seems to be a memory
> leakage, the application runs out of memory.
>
Why don't you just update the exiting line with the new data, as shown 
in the animation examples in 
http://matplotlib.sourceforge.net/examples/animation/index.html ?

For example:

#
import numpy
from numpy.testing.utils import memusage
import matplotlib.pyplot as plt
x = range (1000)
fig = plt.figure()
axes1 = fig.add_subplot( 111 )
y = numpy.random.rand (len (x))
line = None
while 1:
     if not line:
         line, = axes1.plot(x, y, 'b', label='data')
     else:
         line.set_data(x,y)
        fig.canvas.draw()
     print memusage ()/(1024.0*1024.0),"MB", len (axes1.lines)
#eof


Regards,
João Silva


------------------------------------------------------------------------------

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to