From: David H. <dav...@gm...> - 2006-02-24 19:24:26
|
Hi, What one can do is : f =3D figure(1) ... some figure f.clear() f =3D figure(1) ... another figure f.clear() However, it is only a work around, not an actual solution... Cheers, David 2006/2/24, David TREMOUILLES <dav...@gm...>: > > >>2006/2/24, David Huard <dav...@gm... >: > >>What if I want it to be non-interactive ? I want to save graphics > >>directly to a file from a script, without them being displayed. It'= s > >>weird that in this case close() crashes the whole thing. > > Yes your wright the script have to work in non interactive mode. (I was > just trying to give an explanation to Emmanuel problem). > The following script should work (but it crashes like Emmanuel reported)= : > > #!/usr/bin/python > import matplotlib > import pylab > #Turn off interactive mode > matplotlib.interactive(False) > #plot figure 1 > pylab.figure() > pylab.plot([1,2,3],[1,2,3]) > pylab.savefig("test_pylab1.png") > pylab.close() > #plot figure 2 > pylab.figure() > pylab.plot([1,2,3],[1,2,3]) > pylab.savefig("test_pylab2.png") > pylab.close() > > Second figure cannot be created due to the crash. > > We need the help of matplotlib Gurus ! > > Regards, > > David > > > > 2006/2/24, David Huard <dav...@gm...>: > > What if I want it to be non-interactive ? I want to save graphics > > directly to a file from a script, without them being displayed. It's > > weird that in this case close() crashes the whole thing. > > > > David > > > > 2006/2/23, David TREMOUILLES < dav...@gm...>: > > > Could that be because interactive mode was set in your previous insta= ll > ? > > > (in .matplotlibrc file) > > > if I try: > > > > > > #!/usr/bin/python > > > import matplotlib > > > import pylab > > > matplotlib.interactive(True) > > > pylab.figure() > > > pylab.close() > > > > > > Then it works... > > > Hope this could help you... > > > > > > David > > > > > > 2006/2/23, Emmanuel Pecontal <pec...@ob...>: > > > > > > > Hello, > > > > > > > > If I run the following script on my system (SuSE 10.0, matplotlib-0= .87 > but > > > > same behaviour with 0.86): > > > > > > > > #!/usr/bin/python > > > > > > > > import matplotlib > > > > import pylab > > > > > > > > pylab.figure() > > > > pylab.close () > > > > > > > > It crashes with the following error message: > > > > > > > > Traceback (most recent call last): > > > > File "./tmp.py", line 8, in ? > > > > pylab.close() > > > > File > > > "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", > > > line 768, in > > > > close > > > > else: _pylab_helpers.Gcf.destroy(figManager.num) > > > > File > > > > "/usr/lib/python2.4/site-packages/matplotlib/_pylab_helpers.py", > > > line > > > > 28, in destroy > > > > figManager.destroy() > > > > File > > > > "/usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtk.py", > > > > line 456, in destroy > > > > gtk.main_quit() > > > > RuntimeError: called outside of a mainloop > > > > > > > > Does someone has an idea of the problem? > > > > I didn't have this kind of problem with my SuSE 9.3 and > matplotlib-0.85 > > > > > > > > -- > > > > Emmanuel P=E9contal > > > > > > > > CRAL - Observatoire de Lyon > > > > 9, Av. Charles Andre > > > > F-69561 Saint Genis Laval Cedex > > > > > > > > tel (33) (0)4.78.86.83.76 - fax (33) (0)4.78.86.83.86 > > > > > > > > email : pec...@ob... > > > > > > > > > > > > > > |