From: Norbert N. <Nor...@gm...> - 2004-12-02 10:14:10
|
OK, now I understand: my problem was just the ordering of show() and savefig() Doing savefig first and show lateron solved the problem with no further changes... Thanks! Am Donnerstag, 2. Dezember 2004 10:26 schrieb Darren Dale: > On Thursday 02 December 2004 04:12 am, Norbert Nemec wrote: > > Hi there, > > > > probably a trivial question, but somehow, I'm stuck anyway: > > > > I have the following script: > > > > ---------- > > #!/usr/bin/env python > > import matplotlib.matlab > > ... do some data preparation ... > > plot(something) > > show() > > savefig("output.eps") > > ---------- > > > > If I call this script with the -dGtkAgg option, it displays the plot on > > screen and saves an empty eps file. If I call it with -dPS, it displays > > nothing and outputs the correct eps - so far everything as I would expect > > it. > > > > Up to now, I just used the -dGtkAgg backend (as default) to get an > > impression about the plots and then ran the script again to create the > > .eps. > > > > Now, I would like the script to do both in one run: display the plot on > > screen, and save it to disk at the same time. > > > > Somehow I have not achieved doing so. My first idea was to place > > matplotlib.use('PS') > > right before the savefig, but that does not change anything and still > > writes an empty .eps file. > > > > What should I do? > > Hi Norbert, > > Try running this: > > ---------- > #!/usr/bin/env python > matplotlib.use('GTKAgg') > import matplotlib.matlab > ... do some data preparation ... > plot(something) > savefig("output.eps") > show() > ---------- > > That should save the file as eps and show the plot using the GTK backend. > matplotlib.use('PS') would have to be called before importing > matplotlib.matlab, which is why it seemed unresponsive in your script. But > you dont need to call it for what you want to accomplish. -- _________________________________________Norbert Nemec Bernhardstr. 2 ... D-93053 Regensburg Tel: 0941 - 2009638 ... Mobil: 0179 - 7475199 eMail: <No...@Ne...> |