[SciPy-user] Plot window suppression in scipy.gplt

Oleksandr Moskalenko malex at tagancha.org
Thu May 5 15:50:09 EDT 2005


* Oleksandr Moskalenko <malex at tagancha.org> [2005-05-03 15:56:22 -0600]:

> Hi,
> 
> First, thanks for scipy - a great piece of software. I've run into a problem I
> can't resolve with docs and reading the source code. I've been going through
> the mailing lists through the search interface and used Google, but I couldn't
> find information on how I could suppress the plot window that pops up when
> running gplt.plot. I am producing a png hardcopy of the plot with gplt.output
> and that is all I need, really. This script will be used as a back-end for a
> web app and I don't want to see that window pop up on every form submission.
> 
> Thanks,
> 
> Alex

Well,

I haven't received any replies concerning external window suppression when
using gplt. However, I solved my problem by starting with a suggestion found
in http://www.scipy.org/mailinglists/mailman?fn=scipy-user/2003-July/001799.html.
In case someone runs into the same problem later on I'm including a summary of
the working solution. My final code:

         self.outfile = os.path.join(outdir,outname)
         g=gplt.current()
         g._send('set term png')
         self.outcommand = 'set output "%s"; replot' % (self.outfile)
         g._send(self.outcommand)
         gplt.hold('on')
         gplt.plot(self.initxval,self.yinitreal,"title 'Empirical-real' with points pt 4")
         g._send(self.outcommand)
         gplt.plot(self.initxval,self.yinitimag,"title 'Empirical-imag.' with points pt 3")
         g._send(self.outcommand)
         gplt.plot(self.intxval,self.intreal,"title 'Interpolated-real' with lines")
         g._send(self.outcommand)
         gplt.plot(self.intxval,self.intimag,"title 'Interpolated-imag.' with lines")
         g._send(self.outcommand)
         gplt.legend('left top Right enhanced')
         g._send(self.outcommand)
         gplt.title('Cubic-spline interpolation of optical data')
         g._send(self.outcommand)
         gplt.xtitle('Wavelength, nm')
         g._send(self.outcommand)
         gplt.ytitle('Refraction and Conductivity')
         gplt.close()

As you can see it seems necessary to set the output of gnuplot on each
plotting pass, otherwise only the first plot will be found in the output file.
As I am working on a web application with Quixote (a Pythonic web framework) I
also ran into a problem with subsequent runs that added to the previous plot,
so "gplt.close()" was necessary for a clean separation between plots.

This is all that was needed to work.

Regards,

Alex.




More information about the SciPy-User mailing list