updating a plot without calling plot

I'm having some trouble updating a plot window without calling plot. I would
like to do something like:

ax = axes()
lines, = plot([1,2,3], [1,2,3])
lines.set_ydata([4,5,6])
ax.autoscale_view()
ax.draw()

The line does get updated, but the axes limits are not updated. I've looked
into the Axes.plot code, and as far as I can tell, the above code should
work. Can anyone tell me what is the right way to do this?

Darren

I guess I should point out why I can't call plot. I'm rapidly losing physical
memory, even when I call ax.hold(False):

ax = axes() # ipython using 51 MB
ax.plot(arange(1000000)) # ipython using 81 MB
ax.hold(False)
ax.plot(arange(1000000)) # ipython using 138 MB
ax.plot(arange(1000000)) # ipython using 142 MB
ax.hold(True)
ax.plot(arange(1000000)) # ipython using 172 MB
ax.plot(arange(1000000)) # ipython using 203 MB

Darren

···

On Friday 19 October 2007 05:23:38 pm Darren Dale wrote:

I'm having some trouble updating a plot window without calling plot. I
would like to do something like:

ax = axes()
lines, = plot([1,2,3], [1,2,3])
lines.set_ydata([4,5,6])
ax.autoscale_view()
ax.draw()

The line does get updated, but the axes limits are not updated. I've looked
into the Axes.plot code, and as far as I can tell, the above code should
work. Can anyone tell me what is the right way to do this?

Here is the answer:

ax = axes()
lines, = plot([1,2,3], [1,2,3])
lines.set_ydata([4,5,6])
ax.relim()
ax.autoscale_view()
ax.draw()

···

On Friday 19 October 2007 06:16:14 pm Darren Dale wrote:

On Friday 19 October 2007 05:23:38 pm Darren Dale wrote:
> I'm having some trouble updating a plot window without calling plot. I
> would like to do something like:
>
> ax = axes()
> lines, = plot([1,2,3], [1,2,3])
> lines.set_ydata([4,5,6])
> ax.autoscale_view()
> ax.draw()
>
> The line does get updated, but the axes limits are not updated. I've
> looked into the Axes.plot code, and as far as I can tell, the above code
> should work. Can anyone tell me what is the right way to do this?

Yes, you may also want to see if calling gc.collect between your plot
calls frees up some of your memory.

JDH

···

On 10/20/07, Darren Dale <darren.dale@...143...> wrote:

Here is the answer:

ax = axes()
lines, = plot([1,2,3], [1,2,3])
lines.set_ydata([4,5,6])
ax.relim()

Thanks for the suggestion. The good news is, it looks like calling gc.collect
is not necessary when updating the line's ydata and calling relim,
autoscale_view and draw.

Darren

···

On Saturday 20 October 2007 12:42:46 pm John Hunter wrote:

On 10/20/07, Darren Dale <darren.dale@...143...> wrote:
> Here is the answer:
>
> ax = axes()
> lines, = plot([1,2,3], [1,2,3])
> lines.set_ydata([4,5,6])
> ax.relim()

Yes, you may also want to see if calling gc.collect between your plot
calls frees up some of your memory.

Nice to hear you found a solution. Still, it would nice if the obvious way to do it didn't leak memory :wink: I thought the memory leak hunting I did a few months ago had resolved this, but it wasn't testing exactly the same thing -- it was creating figures directly in each iteration, not just calling plot. I'll look into this further.

Cheers,
Mike

Darren Dale wrote:

···

On Friday 19 October 2007 05:23:38 pm Darren Dale wrote:

I'm having some trouble updating a plot window without calling plot. I
would like to do something like:

ax = axes()
lines, = plot([1,2,3], [1,2,3])
lines.set_ydata([4,5,6])
ax.autoscale_view()
ax.draw()

The line does get updated, but the axes limits are not updated. I've looked
into the Axes.plot code, and as far as I can tell, the above code should
work. Can anyone tell me what is the right way to do this?

I guess I should point out why I can't call plot. I'm rapidly losing physical memory, even when I call ax.hold(False):

ax = axes() # ipython using 51 MB
ax.plot(arange(1000000)) # ipython using 81 MB
ax.hold(False)
ax.plot(arange(1000000)) # ipython using 138 MB
ax.plot(arange(1000000)) # ipython using 142 MB
ax.hold(True)
ax.plot(arange(1000000)) # ipython using 172 MB
ax.plot(arange(1000000)) # ipython using 203 MB

Darren

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA