show() problem in Mac OS X 10.5.8

I have a problem with show() command in my macbook machine (Leopard 10.5.8).
For example, if I run the script shown below
(let assume it is saved as 'test.py', and I run a command 'python test.py'),

···

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

plot([1,2,3,4,5])
show() #first window
plot([1,2,3,4,5])
show() #second window
plot([1,2,3,4,5])
show() #third window

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

Then the first window just pops up and I can see a beautiful straight line
:slight_smile: No problem so far.
But, after I close the first window by clicking the close button of the
window,
other two window (second and third) just pops up and close themselves
instantly
even though I didn't click the close button...
Also, the second and third plot is shown in the same window.

I don't have such problem in my Ubuntu machine..

Does anybody know reasons?

Thanks in advance!!

--
View this message in context: http://www.nabble.com/show()-problem-in-Mac-OS-X-10.5.8-tp25047335p25047335.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

show() actually handles starting the GUI mainloop, so you really shouldn’t be calling it more than once from a script. Quite frankly, it’s more amazing that it works on your Ubuntu macine. :slight_smile: If you’re wanting 3 separate windows, try:

plot([1,2,3,4,5])
figure()
plot([1,2,3,4,5])
figure()
plot([1,2,3,4,5])
show()

Ryan

···

On Wed, Aug 19, 2009 at 11:55 AM, coati <dwkim78@…287…> wrote:

I have a problem with show() command in my macbook machine (Leopard 10.5.8).

For example, if I run the script shown below

(let assume it is saved as ‘test.py’, and I run a command ‘python test.py’),


plot([1,2,3,4,5])

show() #first window

plot([1,2,3,4,5])

show() #second window

plot([1,2,3,4,5])

show() #third window


Then the first window just pops up and I can see a beautiful straight line

:slight_smile: No problem so far.

But, after I close the first window by clicking the close button of the

window,

other two window (second and third) just pops up and close themselves

instantly

even though I didn’t click the close button…

Also, the second and third plot is shown in the same window.

I don’t have such problem in my Ubuntu machine…

Does anybody know reasons?


Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Thanks Ryan,

Hm… it’s a bit strange… I just installed matplotlib at Ubuntu using the package manager :slight_smile:
And, another linux machines (red hat enterprise) can do this too. For the RHELs, I compiled matplotlib source code by myself.

figure() works very well, but what I want to do is to check the plots one by one and thus
I can exit the script at any time I want (because I usually have lots of figures to check and I don’t want
to pop up every of them at the same time…)

Anyway, thank you very much!

···

On Wed, Aug 19, 2009 at 1:02 PM, Ryan May <rmay31@…1896…> wrote:

On Wed, Aug 19, 2009 at 11:55 AM, coati <dwkim78@…287…> wrote:

I have a problem with show() command in my macbook machine (Leopard 10.5.8).

For example, if I run the script shown below

(let assume it is saved as ‘test.py’, and I run a command ‘python test.py’),


plot([1,2,3,4,5])

show() #first window

plot([1,2,3,4,5])

show() #second window

plot([1,2,3,4,5])

show() #third window


Then the first window just pops up and I can see a beautiful straight line

:slight_smile: No problem so far.

But, after I close the first window by clicking the close button of the

window,

other two window (second and third) just pops up and close themselves

instantly

even though I didn’t click the close button…

Also, the second and third plot is shown in the same window.

I don’t have such problem in my Ubuntu machine…

Does anybody know reasons?

show() actually handles starting the GUI mainloop, so you really shouldn’t be calling it more than once from a script. Quite frankly, it’s more amazing that it works on your Ubuntu macine. :slight_smile: If you’re wanting 3 separate windows, try:

plot([1,2,3,4,5])

figure()

plot([1,2,3,4,5])

figure()

plot([1,2,3,4,5])
show()

Ryan


Ryan May

Graduate Research Assistant
School of Meteorology
University of Oklahoma

The one ‘preliminary’ solution I found is using an interactive mode + raw_input.
Here is and example,

    ion()
    plot([1,2,3,4,5])
    raw_input('Type Enter')
    clf()

    plot([1,2,3,4,5])
    raw_input('Type_Enter')
    clf()
    plot([1,2,3,4,5])
    show()

With this approach, I can press the enter when I want to see next figure.

Though It’s not as convenient as ‘multiple show()’…

···

On Wed, Aug 19, 2009 at 1:57 PM, Kim, Dae-Won <dwkim78@…287…> wrote:

On Wed, Aug 19, 2009 at 1:02 PM, Ryan May <rmay31@…287…> wrote:

On Wed, Aug 19, 2009 at 11:55 AM, coati <dwkim78@…287…> wrote:

I have a problem with show() command in my macbook machine (Leopard 10.5.8).

For example, if I run the script shown below

(let assume it is saved as ‘test.py’, and I run a command ‘python test.py’),


plot([1,2,3,4,5])

show() #first window

plot([1,2,3,4,5])

show() #second window

plot([1,2,3,4,5])

show() #third window


Then the first window just pops up and I can see a beautiful straight line

:slight_smile: No problem so far.

But, after I close the first window by clicking the close button of the

window,

other two window (second and third) just pops up and close themselves

instantly

even though I didn’t click the close button…

Also, the second and third plot is shown in the same window.

I don’t have such problem in my Ubuntu machine…

Does anybody know reasons?

show() actually handles starting the GUI mainloop, so you really shouldn’t be calling it more than once from a script. Quite frankly, it’s more amazing that it works on your Ubuntu macine. :slight_smile: If you’re wanting 3 separate windows, try:

plot([1,2,3,4,5])

figure()

plot([1,2,3,4,5])

figure()

plot([1,2,3,4,5])
show()

Ryan


Ryan May

Graduate Research Assistant
School of Meteorology
University of Oklahoma

Thanks Ryan,

Hm… it’s a bit strange… I just installed matplotlib at Ubuntu using the package manager :slight_smile:
And, another linux machines (red hat enterprise) can do this too. For the RHELs, I compiled matplotlib source code by myself.

figure() works very well, but what I want to do is to check the plots one by one and thus
I can exit the script at any time I want (because I usually have lots of figures to check and I don’t want
to pop up every of them at the same time…)

Anyway, thank you very much!

Whether or not you can do multiple show()s depends on which backend you use. For example, the Mac OS X native backend has no problems with the multiple show()s in your example. Which backend were you using? While matplotlib does not support multiple show()s in general, there may be a simple solution to get that working for the backend you are using.

--Michiel.

···

--- On Wed, 8/19/09, Kim, Dae-Won <dwkim78@...287...> wrote:

From: Kim, Dae-Won <dwkim78@...287...>
Subject: Re: [Matplotlib-users] show() problem in Mac OS X 10.5.8
To: "Ryan May" <rmay31@...287...>
Cc: matplotlib-users@lists.sourceforge.net
Date: Wednesday, August 19, 2009, 2:48 PM

The one 'preliminary' solution I found is using
an interactive mode + raw_input.
Here is and example,

    ion\(\)
    plot\(\[1,2,3,4,5\]\)
    raw\_input\(&#39;Type Enter&#39;\)
    clf\(\)

    plot\(\[1,2,3,4,5\]\)
    raw\_input\(&#39;Type\_Enter&#39;\)
    clf\(\)
    plot\(\[1,2,3,4,5\]\)
    show\(\)

With this approach, I can press the enter when I want to
see next figure.

Though It's not as convenient as 'multiple
show()'..

On Wed, Aug 19, 2009 at 1:57 PM, > Kim, Dae-Won <dwkim78@...287...> > wrote:

On Wed, Aug 19, 2009 at 1:02 PM, > Ryan May <rmay31@...287...> > wrote:

On Wed, Aug 19, 2009 at 11:55 > AM, coati <dwkim78@...287...> > wrote:

I have a problem with show() command in my macbook
machine (Leopard 10.5.8).

For example, if I run the script shown below

(let assume it is saved as 'test.py', and I run a
command 'python test.py'),

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

plot([1,2,3,4,5])

show() #first window

plot([1,2,3,4,5])

show() #second window

plot([1,2,3,4,5])

show() #third window

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

Then the first window just pops up and I can see a
beautiful straight line

:slight_smile: No problem so far.

But, after I close the first window by clicking the close
button of the

window,

other two window (second and third) just pops up and close
themselves

instantly

even though I didn't click the close button...

Also, the second and third plot is shown in the same
window.

I don't have such problem in my Ubuntu machine..

Does anybody know reasons?
show() actually handles starting the GUI mainloop, so you
really shouldn't be calling it more than once from a
script. Quite frankly, it's more amazing that it works
on your Ubuntu macine. :slight_smile: If you're wanting 3 separate
windows, try:

plot([1,2,3,4,5])
figure()
plot([1,2,3,4,5])
figure()
plot([1,2,3,4,5])
show()

Ryan

--
Ryan May

Graduate Research Assistant
School of Meteorology
University of Oklahoma

Thanks Ryan,

Hm.. it's a bit strange.. I just installed matplotlib
at Ubuntu using the package manager :slight_smile:
And, another linux machines (red hat enterprise) can do
this too. For the RHELs, I compiled matplotlib source code
by myself.

figure() works very well, but what I want to do is to check
the plots one by one and thus
I can exit the script at any time I want (because I usually
have lots of figures to check and I don't want
to pop up every of them at the same time..)

Anyway, thank you very much!

-----Inline Attachment Follows-----

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal
Reports 2008 30-Day
trial. Simplify your report design, integration and
deployment - and focus on
what you do best, core application coding. Discover what's
new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
-----Inline Attachment Follows-----

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

I tested with TKAgg and WXAgg. I just bought macbook and I’m newbie yet. Do I need to set something special for the multiple show()s?

Thanks,

-Dae-Won

···

On Thu, Aug 20, 2009 at 10:01 AM, Michiel de Hoon <mjldehoon@…9…> wrote:

Whether or not you can do multiple show()s depends on which backend you use. For example, the Mac OS X native backend has no problems with the multiple show()s in your example. Which backend were you using? While matplotlib does not support multiple show()s in general, there may be a simple solution to get that working for the backend you are using.

–Michiel.

— On Wed, 8/19/09, Kim, Dae-Won <dwkim78@…287…> wrote:

From: Kim, Dae-Won <dwkim78@…878…287…>

Subject: Re: [Matplotlib-users] show() problem in Mac OS X 10.5.8

To: “Ryan May” <rmay31@…287…>

Cc: matplotlib-users@lists.sourceforge.net

Date: Wednesday, August 19, 2009, 2:48 PM

The one ‘preliminary’ solution I found is using

an interactive mode + raw_input.

Here is and example,

    ion()
    plot([1,2,3,4,5])
    raw_input('Type Enter')
    clf()
    plot([1,2,3,4,5])
    raw_input('Type_Enter')
    clf()
    plot([1,2,3,4,5])
    show()

With this approach, I can press the enter when I want to

see next figure.

Though It’s not as convenient as 'multiple

show()'…

On Wed, Aug 19, 2009 at 1:57 PM, > > > Kim, Dae-Won <dwkim78@…1896…> > > > wrote:

On Wed, Aug 19, 2009 at 1:02 PM, > > > Ryan May <rmay31@…287…> > > > wrote:

On Wed, Aug 19, 2009 at 11:55 > > > AM, coati <dwkim78@…287…> > > > wrote:

I have a problem with show() command in my macbook

machine (Leopard 10.5.8).

For example, if I run the script shown below

(let assume it is saved as ‘test.py’, and I run a

command ‘python test.py’),


plot([1,2,3,4,5])

show() #first window

plot([1,2,3,4,5])

show() #second window

plot([1,2,3,4,5])

show() #third window


Then the first window just pops up and I can see a

beautiful straight line

:slight_smile: No problem so far.

But, after I close the first window by clicking the close

button of the

window,

other two window (second and third) just pops up and close

themselves

instantly

even though I didn’t click the close button…

Also, the second and third plot is shown in the same

window.

I don’t have such problem in my Ubuntu machine…

Does anybody know reasons?

show() actually handles starting the GUI mainloop, so you

really shouldn’t be calling it more than once from a

script. Quite frankly, it’s more amazing that it works

on your Ubuntu macine. :slight_smile: If you’re wanting 3 separate

windows, try:

plot([1,2,3,4,5])

figure()

plot([1,2,3,4,5])

figure()

plot([1,2,3,4,5])

show()

Ryan

Ryan May

Graduate Research Assistant

School of Meteorology

University of Oklahoma

Thanks Ryan,

Hm… it’s a bit strange… I just installed matplotlib

at Ubuntu using the package manager :slight_smile:

And, another linux machines (red hat enterprise) can do

this too. For the RHELs, I compiled matplotlib source code

by myself.

figure() works very well, but what I want to do is to check

the plots one by one and thus

I can exit the script at any time I want (because I usually

have lots of figures to check and I don’t want

to pop up every of them at the same time…)

Anyway, thank you very much!

-----Inline Attachment Follows-----


Let Crystal Reports handle the reporting - Free Crystal

Reports 2008 30-Day

trial. Simplify your report design, integration and

deployment - and focus on

what you do best, core application coding. Discover what’s

new with

Crystal Reports now. http://p.sf.net/sfu/bobj-july

-----Inline Attachment Follows-----


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Does anybody know why the show._needmain stuff is needed in the show() function in backend_tkagg.py? Currently, this function is as follows:

def show():
    """
    Show all the figures and enter the gtk mainloop

    This should be the last line of your script. This function sets
    interactive mode to True, as detailed on
    http://matplotlib.sf.net/interactive.html
    """
    for manager in Gcf.get_all_fig_managers():
        manager.show()
    import matplotlib
    matplotlib.interactive(True)
    if rcParams['tk.pythoninspect']:
        os.environ['PYTHONINSPECT'] = '1'
    if show._needmain:
        Tk.mainloop()
        show._needmain = False
show._needmain = True

If I remove the show._needmain stuff, as in:

def show():
    """
    Show all the figures and enter the gtk mainloop

    This should be the last line of your script. This function sets
    interactive mode to True, as detailed on
    http://matplotlib.sf.net/interactive.html
    """
    for manager in Gcf.get_all_fig_managers():
        manager.show()
    import matplotlib
    matplotlib.interactive(True)
    if rcParams['tk.pythoninspect']:
        os.environ['PYTHONINSPECT'] = '1'
    Tk.mainloop()

then the function still seems to work fine, and multiple show()s also works.

--Michiel.

···

--- On Thu, 8/20/09, Kim, Dae-Won <dwkim78@...287...> wrote:

From: Kim, Dae-Won <dwkim78@...287...>
Subject: Re: [Matplotlib-users] show() problem in Mac OS X 10.5.8
To: "Michiel de Hoon" <mjldehoon@...9...>
Cc: "Ryan May" <rmay31@...287...>, matplotlib-users@lists.sourceforge.net
Date: Thursday, August 20, 2009, 10:26 AM

I tested with TKAgg and WXAgg. I just bought macbook and
I'm newbie yet. Do I need to set something special for
the multiple show()s?

Thanks,

-Dae-Won

On Thu, Aug 20, 2009 at 10:01 AM, > Michiel de Hoon <mjldehoon@...9...> > wrote:

Whether or not you can do multiple
show()s depends on which backend you use. For example, the
Mac OS X native backend has no problems with the multiple
show()s in your example. Which backend were you using? While
matplotlib does not support multiple show()s in general,
there may be a simple solution to get that working for the
backend you are using.

--Michiel.

--- On Wed, 8/19/09, Kim, Dae-Won <dwkim78@...287...> > wrote:

> From: Kim, Dae-Won <dwkim78@...287...>

> Subject: Re: [Matplotlib-users] show() problem in Mac
OS X 10.5.8

> To: "Ryan May" <rmay31@...287...>

> Cc: matplotlib-users@lists.sourceforge.net

> Date: Wednesday, August 19, 2009, 2:48 PM

>

> The one 'preliminary' solution I found is
using

> an interactive mode + raw_input.

> Here is and example,

>

> ion()

> plot([1,2,3,4,5])

> raw_input('Type Enter')

> clf()

>

>

> plot([1,2,3,4,5])

> raw_input('Type_Enter')

> clf()

> plot([1,2,3,4,5])

> show()

>

> With this approach, I can press the enter when I want
to

> see next figure.

>

>

>

> Though It's not as convenient as 'multiple

> show()'..

>

>

> On Wed, Aug 19, 2009 at 1:57 PM, > > > Kim, Dae-Won <dwkim78@...287...> > > > wrote:

>

>

>

>

> On Wed, Aug 19, 2009 at 1:02 PM, > > > Ryan May <rmay31@...287...> > > > wrote:

>

>

>

> On Wed, Aug 19, 2009 at 11:55 > > > AM, coati <dwkim78@...287...> > > > wrote:

>

>

>

>

>

>

>

> I have a problem with show() command in my macbook

> machine (Leopard 10.5.8).

>

> For example, if I run the script shown below

>

> (let assume it is saved as 'test.py', and I
run a

> command 'python test.py'),

>

>

>

> ---------------------------------------

>

>

>

> plot([1,2,3,4,5])

>

> show() #first window

>

> plot([1,2,3,4,5])

>

> show() #second window

>

> plot([1,2,3,4,5])

>

> show() #third window

>

>

>

> ---------------------------------------

>

>

>

> Then the first window just pops up and I can see a

> beautiful straight line

>

> :slight_smile: No problem so far.

>

> But, after I close the first window by clicking the
close

> button of the

>

> window,

>

> other two window (second and third) just pops up and
close

> themselves

>

> instantly

>

> even though I didn't click the close button...

>

> Also, the second and third plot is shown in the same

> window.

>

>

>

> I don't have such problem in my Ubuntu machine..

>

>

>

> Does anybody know reasons?

> show() actually handles starting the GUI mainloop, so
you

> really shouldn't be calling it more than once from
a

> script. Quite frankly, it's more amazing that it
works

> on your Ubuntu macine. :slight_smile: If you're wanting 3
separate

> windows, try:

>

>

>

>

>

>

> plot([1,2,3,4,5])

> figure()

> plot([1,2,3,4,5])

> figure()

> plot([1,2,3,4,5])

> show()

>

> Ryan

>

> --

> Ryan May

>

> Graduate Research Assistant

> School of Meteorology

> University of Oklahoma

>

>

>

>

>

> Thanks Ryan,

>

> Hm.. it's a bit strange.. I just installed
matplotlib

> at Ubuntu using the package manager :slight_smile:

> And, another linux machines (red hat enterprise) can
do

> this too. For the RHELs, I compiled matplotlib source
code

> by myself.

>

>

>

>

>

> figure() works very well, but what I want to do is to
check

> the plots one by one and thus

> I can exit the script at any time I want (because I
usually

> have lots of figures to check and I don't want

> to pop up every of them at the same time..)

>

>

>

>

>

> Anyway, thank you very much!

>

>

>

>

>

>

>

> -----Inline Attachment Follows-----

>

>
------------------------------------------------------------------------------

> Let Crystal Reports handle the reporting - Free
Crystal

> Reports 2008 30-Day

> trial. Simplify your report design, integration and

> deployment - and focus on

> what you do best, core application coding. Discover
what's

> new with

> Crystal Reports now. http://p.sf.net/sfu/bobj-july

> -----Inline Attachment Follows-----

>

> _______________________________________________

> Matplotlib-users mailing list

> Matplotlib-users@lists.sourceforge.net

> matplotlib-users List Signup and Options

>

Define "works". It seems to me that you could
then have a script that tries to enter the mainloop
multiple times. I suspect "works" means that in
an interactive session you can enter and leave
the mainloop repeatedly?

Alan Isaac
(just another user)

···

On 8/22/2009 2:42 AM Michiel de Hoon apparently wrote:

Does anybody know why the show._needmain stuff is needed in the show() function in backend_tkagg.py?...
If I remove the show._needmain stuff ...
then the function still seems to work fine, and multiple show()s also works.