plot multiple times in one script fails

Hello,

I'm totally new to matplotlib, so sorry if the question is stupid.

I'm trying this slightly modified example from the examples page

from pylab import *
A = rand(5,5)
figure(1)
imshow(A, interpolation='bicubic')
show()
close(1)

A = rand(5,5)
figure(2)
imshow(A, interpolation='bicubic')
show()
close(2)

The first figure is drawn without problems but after closing it (by clicking
the cross in the upper
right corner of the window) the second figure cannot be plot anymore. What I
wanted to do was
to visualize all selected files of a directory one after the other. To do
this I want to close the old
figure and then the new figure should com up as long as there is a file to
visualize left. Unfortunaltely
only the first figure is shown as in the simple example.
So, what's wrong?

I'm using Windows XP and the newst version of matplotlib.

···

--
View this message in context: http://www.nabble.com/plot-multiple-times-in-one-script-fails-tp25020909p25020909.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Calling show() multiple times is not supported.

Ryan

···

On Tue, Aug 18, 2009 at 3:55 AM, M. Hecht <mhecht2909@…2740…> wrote:

Hello,

I’m totally new to matplotlib, so sorry if the question is stupid.

I’m trying this slightly modified example from the examples page

from pylab import *

A = rand(5,5)

figure(1)

imshow(A, interpolation=‘bicubic’)

show()

close(1)

A = rand(5,5)

figure(2)

imshow(A, interpolation=‘bicubic’)

show()

close(2)

The first figure is drawn without problems but after closing it (by clicking

the cross in the upper

right corner of the window) the second figure cannot be plot anymore. What I

wanted to do was

to visualize all selected files of a directory one after the other. To do

this I want to close the old

figure and then the new figure should com up as long as there is a file to

visualize left. Unfortunaltely

only the first figure is shown as in the simple example.

So, what’s wrong?


Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

We don't really have support for blocking input where a program is
halted until you close the open figure, and then the next one loads.
You could write something using event handling, where on a key press
event the next figure was loaded. You may also be able to use ginput
here, which will give you a blocking input function.

See

http://matplotlib.sourceforge.net/users/shell.html

http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.ginput

http://matplotlib.sourceforge.net/users/event_handling.html

http://matplotlib.sourceforge.net/examples/pylab_examples/ginput_demo.html

···

On Tue, Aug 18, 2009 at 3:55 AM, M. Hecht<mhecht2909@...2739...> wrote:

The first figure is drawn without problems but after closing it (by clicking
the cross in the upper
right corner of the window) the second figure cannot be plot anymore. What I
wanted to do was
to visualize all selected files of a directory one after the other. To do
this I want to close the old
figure and then the new figure should com up as long as there is a file to
visualize left. Unfortunaltely
only the first figure is shown as in the simple example.
So, what's wrong

Hi,

ok meanwhile I found out that this is a typical beginners error, sorry.

Nevertheless, using ion(), and ioff() together with draw() works fine.

What I didn't find out up to now was the funtion

   ginput(n=1, timeout=30, show_clicks=True)

which prevents me from killing the window after every plot, so
thank you John Hunter-4. Before it was even not possible to
move the focus to another window without crashing the application.

Now all behaves as "expected".

Thank you again.

John Hunter-4 wrote:

···

On Tue, Aug 18, 2009 at 3:55 AM, M. Hecht<mhecht2909@...2739...> > wrote:

The first figure is drawn without problems but after closing it (by
clicking
the cross in the upper
right corner of the window) the second figure cannot be plot anymore.
What I
wanted to do was
to visualize all selected files of a directory one after the other. To do
this I want to close the old
figure and then the new figure should com up as long as there is a file
to
visualize left. Unfortunaltely
only the first figure is shown as in the simple example.
So, what's wrong

We don't really have support for blocking input where a program is
halted until you close the open figure, and then the next one loads.
You could write something using event handling, where on a key press
event the next figure was loaded. You may also be able to use ginput
here, which will give you a blocking input function.

See

http://matplotlib.sourceforge.net/users/shell.html

http://matplotlib.sourceforge.net/api/figure_api.html#matplotlib.figure.Figure.ginput

http://matplotlib.sourceforge.net/users/event_handling.html

http://matplotlib.sourceforge.net/examples/pylab_examples/ginput_demo.html

------------------------------------------------------------------------------
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
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://www.nabble.com/plot-multiple-times-in-one-script-fails-tp25020909p25064644.html
Sent from the matplotlib - users mailing list archive at Nabble.com.