On Mon, 30 Jul 2007, Sven Schreiber wrote:
Sven Schreiber schrieb:
> Hi,
> I'm experiencing a problem when saving a plot to pdf or eps.
After some experimentation it seems that the only way to save
the appearance I want in a file is to save to png. This is ok as
a workaround but of course I would prefer a vector format, eps
or pdf.
Thanks for the detailed report. I'll take a look at the things
you mention, but here's an initial response.
The trouble is that, although gnuplot is an excellent program, and
although one of its strong points is the number of graphics
formats it supports, the drivers for the various formats are a
sort of conglomeration. The syntax differs from driver to driver,
and also from version to version of gnuplot. (One expects some
differences in allowable commands for the different drivers, given
that they target graphics formats with different capabilities, but
the actual differences go beyond this, and reflect the histories
of the various chunks of code employed.)
The consequence is this: Suppose you have a set of gnuplot
commands fine-tuned to produce a PNG of the desired appearance.
Now you want EPS or PDF, looking the same. You can't just replace
"set term png" with (e.g.) "set term post" and expect things to
work; you have to construct a new set of commands for the fonts,
colors and line-types, and the precise specification will depend
on the gnuplot version.
Since PNG is the format chosen for on-screen display in gretl,
I've invested a lot of time in controlling gnuplot's PNG output,
including work-arounds for different versions of the PNG driver.
Since EMF is likely to be used a lot on Windows, I've also
invested quite a lot of time in that. (After you've fiddled with
the PNG output, you should hopefully find that the EMF output
looks much the same. I had to hack on the EMF driver in the
version of gnuplot supplied with gretl for Windows to make this
happen.) EPS and PDF have been given some attention, but not so
much.
Things would be somewhat easier if we always knew exactly which
(unique) version of gnuplot gretl is calling. This is the case
under Windows and OS X, where gnuplot is supplied with gretl.
Unfortunately, it's difficult to arrange this on Linux because
gnuplot's capabilities depend on various third party libraries,
which may or may not exist on the host, and may exist in various
mutually incompatible versions. (Libpng versioning in particular
is a horrible mess.)
In the short term, the recipe for getting precise control over EPS
or PDF output is:
1 Make the graph and save it as an icon.
2 Right-click on the icon and choose "Edit gnuplot commands"
3 Save the gnuplot command file under a chosen name.
4 Open the command file in an editor and tweak it, making
reference to the gnuplot documentation.
5 Process the command file with gnuplot itself.
Step 4 could be (semi-)automated using sed, perl or whatever, if
you do a lot of this.
Allin.