Gnuplot PDF Terminal

Posted On April 14, 2008

Filed under Gnuplot
Tags: , , ,

Comments Dropped one response

When producing plots of data by gnuplot one can specify many different output formats:

set terminal png
set output 'plot.png'
plot ...

The output file ‘plot.png’ will contain the image. By replacing ‘png’ by some other format, like ‘gif’ one can change the output format.

Often when producing PDF documents with LaTeX one would like to use images in PDF format for better quality. However due to licensing problems usual installations of gnuplot don’t support PDF output format. One could recompile gnuplot and include the feature manually. But this seems like a lot of hassle especially if you want to produce just one image.

However there is a work around:

set terminal postscript enhanced color

set output '| ps2pdf - plot.pdf'
plot ......

Here we are directing the PS stream into ps2pdf (the ‘-’ sign in the command states to read the PS file from stdin).

Sometimes the PDF files produced have an extra white border, but there are ways to fight with it. I see this as an easy solution to a small problem. Of course if you want many top quality PDF images, you should recompile gnuplot with PDF support.

Inspired by this post .

One Response to “ Gnuplot PDF Terminal ”

  1. Stefan

    This was exactly what I needed so badly. Tank you very much, it works great :)

Respond now.