figure: underlying C/C++ object has been deleted

Thanks! :smiley:

Thank you very much. The ipython -pylab is working great!

Tomislav

P.S.

Enjoy the Hawaiian sunshine… :smiley: I’m freezing in Munich, Germany…

···

----- Original Message -----

From: Eric Firing

Sent: 03/15/10 07:59 PM

To: tomislav_maric@…2537…

Subject: Re: [Matplotlib-users] figure: underlying C/C++ object has been deleted

tomislav_maric@...2537... wrote:
[...]
>
> Here is the code with the error:
>
>
> http://pastebin.com/3QUws70n
>
>
>
> I don't understand, why would a figure object get deleted after it's
> shown on the screen? What am I doing wrong?

This is a common "gotcha": don't use pyplot.show() anywhere other than
at the end of a script, and then only when you want the script to
display a figure and block. For working interactively with ipython
(which it appears you are doing, and which is recommended), use "ipython
-pylab". Then, the figure will be redrawn automatically after pyplot
functions are called. If you use a more OO approach, say using the
Axes.plot(...) method rather than the pyplot.plot(...) function, you can
use pyplot.draw() to force an update when you want one.

Eric

>
>
> Thanks in advance,
>
> Tomislav