From: Darren D. <dd...@co...> - 2004-12-02 09:27:49
|
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. -- Darren |