I have a problem where I need to quickly inspect 20-30 plots. I want
to open a
plotting window, plot the first plot, then hit return to see the nest
plot appear
in the same window.
Below is my script, but it creates a window that has to be closed
before it
loops over the rest of the plots. How can I avoid that the first plot
has to
be closed "manually"?
Cheers
Tommy
Note: I know confirm() is overkill, but I just ripped it out of a
different program
to quickly put this script together :)
import pylab
from optparse import OptionParser
parser = OptionParser(version="%prog 0.01a")
parser.add_option("-i","--infile", dest="infname", action="store",
help="The input file", metavar="INFILE")
parser.add_option("-n","--num", dest="n", action="store",type="int",
help="number of files", metavar="N")
(options,args) = parser.parse_args()
def confirm(_prompt=None, _default=False):
"""prompts for yes or no response. Return True for yes and False
for no."""
promptstr = _prompt
if (not promptstr):
promptstr = "Confirm"
if (_default):
prompt = "%s [%s]|%s: " % (promptstr, "y", "n")
else:
prompt = "%s [%s]|%s: " % (promptstr, "n", "y")
while (True):
ans = raw_input(prompt)
if (not ans):
return _default
if ((ans != "y") and (ans != "Y") and (ans != "n") and (ans !
= "N")):
print "please enter again y or n."
continue
if ((ans == "y") or (ans == "Y")):
return True
if ((ans == "n") or (ans == "N")):
return False
pylab.figure(figsize=(12,14))
for i in xrange(1,options.n+1):
t_list = []
a_list = []
e_list = []
i_list = []
q_list = []
Q_list = []
fname = "%s%02i.aei" % (options.infname,i)
print fname
all_lines = open(fname,"r").readlines()
n=0
for lines in all_lines:
if n > 3:
t_in,a_in,e_in,i_in,peri_in,node_in,M_in,mass =
lines.split()
t_list.append(float(t_in))
a_list.append(float(a_in))
e_list.append(float(e_in))
i_list.append(float(i_in))
q_list.append(float(float(a_in)*(1. - float(e_in))))
Q_list.append(float(float(a_in)*(1. + float(e_in))))
n+=1
pylab.clf()
pylab.subplot(321)
pylab.plot(t_list,a_list,'r-')
pylab.plot(t_list,Q_list,'b-')
pylab.plot(t_list,q_list,'g-')
pylab.subplot(322)
pylab.plot(t_list,a_list,'r-')
pylab.subplot(323)
pylab.plot(t_list,Q_list,'b-')
pylab.subplot(324)
pylab.plot(t_list,q_list,'g-')
pylab.subplot(325)
pylab.plot(t_list,e_list,'r-')
pylab.subplot(326)
pylab.plot(t_list,i_list,'r-')
# if i == 1: pylab.show()
end = confirm("Finished?")
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users