Gnuplot output to PDF (via eps).

  • First, make a gnuplot "plot" file which uses "postscript" terminal output
    Although the new gnuplot supports pdf terminal output - it doesn't seem as full featured as the eps/pdf output.
    The important terminal lines are as follows:
    set terminal postscript portrait enhanced color dashed lw 1 "DejaVuSans" 12
    set output "temp.ps"

  • Next run gnuplot on your plot file:
    gnuplot temp.plot
  • Then convert the eps to pdf:
    epstopdf temp.ps
  • Then use pdfcrop to make sure the bounding box is aligned with the output:
    pdfcrop temp.pdf; mv temp-crop.pdf temp.pdf
  • This can all be done via a script (eg: save it as gnuplotcrop):
    #!/usr/bin
    bn=`basename $1 .plot`
    gnuplot $bn.plot
    epstopdf $bn.ps
    pdfcrop $bn.pdf
    mv $bn-crop.pdf $bn.pdf
    
  • Then, just run gnuplotcrop file.plot - make sure the output is defined as file.ps inside this file.