How to close the figure after show it?

Hi All,

I am using matplotlab to plot some figure. I would like to close the figure after show it 5 sec. My code is pasted below. However, I can not close the figure automatically. Can anyone help me to fix it?

Thanks,
Brook

···

==========================
import time
from pylab import *
from matplotlib import *
x=**
y=**
x2=**
y2=***
figure()
hold(True)
plot(x,y)
plot(x2,y2,‘g^’)
axis([0, 100, 0, 100])
title(‘Pylab plot’)
xlabel(‘X’)
ylabel(‘Y’)
grid()
pylab.show()
time.sleep(5)
pylab.close()


Looking for last minute shopping deals?
Find them fast with Yahoo! Search.

I think f = figure();

pylab.close(f);

should work.

–Mike

···

On Mar 20, 2008, at 2:14 PM, Fans Gnu wrote:

Hi All,

I am using matplotlab to plot some figure. I would like to close the figure after show it 5 sec. My code is pasted below. However, I can not close the figure automatically. Can anyone help me to fix it?

Thanks,
Brook

==========================
import time
from pylab import *
from matplotlib import *
x=**
y=**
x2=**
y2=***
figure()
hold(True)
plot(x,y)
plot(x2,y2,‘g^’)
axis([0, 100, 0, 100])
title(‘Pylab plot’)
xlabel(‘X’)
ylabel(‘Y’)
grid()
pylab.show()
time.sleep(5)
pylab.close()


Looking for last minute shopping deals? Find them fast with Yahoo! Search.

This SF.net email is sponsored by: Microsoft

Defy all challenges. Microsoft® Visual Studio 2008.

http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________

Matplotlib-users mailing list

Matplotlib-users@…813…ourceforge.net

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


Michael Hearne

mhearne@…924…

(303) 273-8620

USGS National Earthquake Information Center

1711 Illinois St. Golden CO 80401

Senior Software Engineer

Synergetics, Inc.


Hi Mike,thanks for your reply. I tried f=figure() and pylab.close(f), but the figure can not be closed automatically. Seems that time.sleep(3) doesn’t be called until I close the figure manually. The test code is attached below.

Thanks,
Brook

···

==================================
from pylab import *
from matplotlib import *
from pylab import figure, close, show, nx
from matplotlib.figure import Figure
import time

x=arange(10)
y=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
x2=arange(20)
y2=arange(20)

f=figure()
hold(True)
plot(x,y)
plot(x2,y2)
grid()
pylab.show()
time.sleep(3)
pylab.close(f)


Looking for last minute shopping deals?
Find them fast with Yahoo! Search.

Hi,

Hi Mike,thanks for your reply. I tried f=figure() and pylab.close(f),
but the figure can not be closed automatically. Seems that

> time.sleep(3) doesn't be called until I close the figure manually.

Maybe try setting the figure's interactive property to on?

···

--
Chris

Can you give me a simple example to show how to set the figure’s interactive property to on? I appreciate!
–Brook

···

— On Fri, 3/21/08, Christopher Brown <c-b@…1861…> wrote:

From: Christopher Brown <c-b@…1861…>
Subject: Re: [Matplotlib-users] How to close the figure after show it?
To: gnu.fans@…9…
Cc: matplotlib-users@lists.sourceforge.net
Date: Friday, March 21, 2008, 12:19 AM

Hi,

> Hi Mike,thanks for your reply. I tried f=figure() and pylab.close(f),
> but the figure can not be closed automatically. Seems that
 > time.sleep(3) doesn't be called until I close the figure manually.

Maybe try setting the figure's interactive property to on?

 --

Chris

Looking for last minute shopping deals?
Find them fast with Yahoo! Search.

Hi Brook,

···

Can you give me a simple example to show how to set the figure's
interactive property to on? I appreciate!

>>> import pylab
>>> pylab.ion()

--
Chris