From: Emmanuel P. <pec...@ob...> - 2006-02-25 16:45:17
|
Hi David, I was in non interactive mode. But I finally solved the problem by replacin= g=20 the GTKAgg backend by the TkAgg one. I don't understand why the GTKAgg does= =20 not work, but well... if the TkAgg does... Emmanuel Le Vendredi 24 F=C3=A9vrier 2006 16:47, David TREMOUILLES a =C3=A9crit=C2= =A0: > >>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.87but 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=C3=A9contal > > > > > > > > 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... =2D-=20 Emmanuel P=C3=A9contal CRAL - Observatoire de Lyon 9, Av. Charles Andre =46-69561 Saint Genis Laval Cedex tel (33) (0)4.78.86.83.76 - fax (33) (0)4.78.86.83.86 email : pec...@ob... ~ |