[Tutor] Closing a matplotlib window after show()

zhengqing gan zhengqinggan at gmail.com
Tue Feb 9 16:41:58 CET 2010


Hi,
    recently I have the same problem with Matplotlib.
    I wrote a wxpython program which can plot a graph when click a button.
    When I click the button first time, I got the plot correct, but when I
closed the figure, and clicked the button again, the code crashed. I have to
reopen the program, and the same problem happened.
    The solution is that put "import matplotlib.pyplot as plt"  before you
plot anything. Then everything works fine.
     I don't know why. It seems that when you close the figure, the imported
module or function stop working. It has to be imported every time.



On Tue, Feb 9, 2010 at 5:00 AM, <tutor-request at python.org> wrote:

> Send Tutor mailing list submissions to
>        tutor at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>        tutor-request at python.org
>
> You can reach the person managing the list at
>        tutor-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>   1. python (ailx ailx)
>   2. Re: python (Luke Paireepinart)
>   3. Re: Closing a matplotlib window after show() (Wayne Watson)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 9 Feb 2010 10:54:06 +0800
> From: ailx ailx <ailxroot at gmail.com>
> To: tutor at python.org
> Subject: [Tutor] python
> Message-ID:
>        <5fc821071002081854k2fa92309ned9389b9f3d915e5 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> python
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20100209/a46c4683/attachment-0001.htm
> >
>
> ------------------------------
>
> Message: 2
> Date: Mon, 8 Feb 2010 21:09:59 -0600
> From: Luke Paireepinart <rabidpoobear at gmail.com>
> To: ailx ailx <ailxroot at gmail.com>
> Cc: tutor at python.org
> Subject: Re: [Tutor] python
> Message-ID:
>        <dfeb4471002081909t496fc217w355010e085b6698d at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> quite.
>
> On Mon, Feb 8, 2010 at 8:54 PM, ailx ailx <ailxroot at gmail.com> wrote:
>
> > python
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20100208/b19399fe/attachment-0001.htm
> >
>
> ------------------------------
>
> Message: 3
> Date: Mon, 08 Feb 2010 21:53:39 -0800
> From: Wayne Watson <sierra_mtnview at sbcglobal.net>
> To: Eike Welk <eike.welk at gmx.net>
> Cc: tutor at python.org
> Subject: Re: [Tutor] Closing a matplotlib window after show()
> Message-ID: <4B70F863.1070407 at sbcglobal.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Hi, I'm not so sure that's true. I have a large 900 line program where
> some original plot code just continues beyond plot() and show(), after
> the user closes the plot window. New code that I put in gets knotted up,
> as far as I can tell. In both cases, I've put print statements after
> show(), but nothing appears in the shell or, if run  by clicking the
> program file, in the DOS-like window that appears.
>
> Further, I posted this elsewhere, and someone claims to have tried a few
> simple examples with show() at the ended,and they did not get tied up in
> knots when the user closed the window. I'm going to assume he used IDLE,
> or a  straight execute of the file.
>
> On 2/8/2010 2:23 PM, Eike Welk wrote:
> > Hello Wayne!
> >
> > On Monday February 8 2010 20:54:27 Wayne Watson wrote:
> >
> >> The basic problem is the show(). One person checked out the examples I
> >> provided and found show() to operate fine. On my XP machine the program
> >> I'm modifying has plot code someone put in a year or two ago, and it all
> >> works fine. My code produces the desired plot, but gets hung up on
> show().
> >>
> > The behavior that you describe, is the normal behavior of Matplotlib:
> When you
> > call show(), the program gets stuck.
> >
> > Therefore the call to show is always the last statement in the example
> > programs. Show returns when the last plot window is closed, and in
> principle
> > the program could then continue.
> >
> > If you want to look at plots while the program is running, you must use
> > Ipython. This is a modified Python interpreter, that contains special
> code to
> > change the way how Matplotlib works.
> >
> > http://ipython.scipy.org/moin/
> >
> >
> > Eike.
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
>
> --
> "Crime is way down. War is declining. And that's far from the good
> news." -- Steven Pinker (and other sources) Why is this true, but yet
> the media says otherwise? The media knows very well how to manipulate us
> (see limbic, emotion, $$). -- WTW
>
>
> ------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
> End of Tutor Digest, Vol 72, Issue 34
> *************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100209/f8327dd7/attachment.htm>


More information about the Tutor mailing list