On Fri, May 28, 2010 9:15 pm, John Hunter wrote:
> On Fri, May 28, 2010 at 1:04 PM, Pearu Peterson <[email protected]> wrote:
>
>> Regarding reusing existing line --- I have understood that this
>> will work only if the length of the line data does not change.
>
> This is not correct -- you can change the line length with calls to
> set_data
>
>> In my case the data grows as more data points are acquired and I have
>> not figured out how to make axes to set new limits after changing
>> the line data.
>
> ax.relim()
Ok, very good. However, it does not seem to have effect. Consider
the following example:
#
import numpy
from numpy.testing.utils import memusage
import matplotlib
matplotlib.use('GTKAgg')
import matplotlib.pyplot as plt
fig = plt.figure()
axes1 = fig.add_subplot( 111 )
def animate():
x = [0]
while 1:
y = numpy.random.rand (len (x))
if 1:
# updating line in place
if not axes1.lines:
line, = axes1.plot(x, y, 'b')
else:
line.set_data(x, y)
# relim does not have effect in updating axes
axes1.relim()
else:
# demonstrates expected behaviour, has leakage w/o Mike patch
for line in axes1.lines:
line.remove()
line, = axes1.plot(x, y, 'b')
fig.canvas.draw()
print memusage ()/(1024.0*1024.0),"MB", len (axes1.lines), len(x)
x.append(x[-1]+1)
import gobject
print 'adding idle'
gobject.idle_add(animate)
print 'showing'
plt.show()
#eof
While the new data is plotted correctly, the plot shows fixed axes
from the first plot call. What I am doing wrong?
Pearu
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel