[SciPy-dev] Saving plots

Derek Homeier derek at physast.uga.edu
Tue Oct 7 18:52:41 CDT 2003

On Thursday, October 2, 2003, at 03:32  AM, Martin Kuemmel wrote:

> I am working since  a month now with python,
> and I have to say that I am impressed about its
> capabilities. Now I encountered a problem, and
> hope there will be a solution in scientific
> python. I have to make plots in a noninteractive
> way, and I have to store them in a html-compatible
> format like gif, or jpeg, or png or whatsever.
> The help of the plotting package says that
> plots can be saved, but the format is not
> specified. So, is the a way to get gif's, jpg'or
> similar??
I haven't worked with scipy's gnuplot module for some time,
and have not yet switched to employ chaco for major work,
but since no one else has responded yet, maybe I can help
you out. There are a number of different interfaces to
use gnuplot from python, and gnuplot, as you might know,
has numerous drivers to plot to at least 20 output formats.
I am currently using the python's Gnuplot module, which is
independent of scipy. That supports basically output to
various terminal drivers (x11 etc.) and output to postscript
with the "hardcopy" function. Unfortunately I am not aware of
an easy way to directly hardcopy to other formats.
But I think scipy's gplt package might do  this, if you check out
the plotting documentation on the scipy site (as I said, I
haven't used this in a while).
Another way would be to first create postscript output from
Gnuplot or gplt and then convert it externally, e.g. with
the Imagemagick package, which is readily scriptable and
available for most Unix systems, just do "convert plot.ps plot.png".
This actually has the advantage of getting the much superior
layout that gnuplot provides with the postscript driver
compared to other output formats, e.g. Greek letters and other
symbols, better axis labelling etc.


More information about the Scipy-dev mailing list