I’ve had some fun creating plots in gnuplot lately, and happened across one of those “it works everywhere but not for my setup” type problems. Here’s my setup/aims:
- using Mac OS X 10.6 and gnuplot 4.6
- generate plots to use in LaTeX, i.e. either PDF or EPS output
- change the standard ratio of the plot canvas from around 4:3 to “a bit wider and less high” (in order to fit the standard width of my 1 column LaTeX text without taking up half of the page)
- have no or only little unnecessary whitespace around the plot
This seems to be impossible in gnuplot, as the usual (since gnuplot 4.4 or so) way to change the plot and canvas size “set size …” works differently for the postscript terminal. You can change the plot size or aspect ratio, but not the canvas size, which results in lots of whitespace around the plot, see the picture below where the blue frame marks the bounding box of the resulting eps.
This is obviously not great, but there seems to be now way around it other than manually removing the whitespace, e.g. in Preview. After some digging, however, I came across the eps2eps tool (happened to be installed on my machine already) which “fixes” the bounding box and removes unnecessary whitespace. Unfortunately, for some unknown reason, it also rotates the resulting image by 90 degrees clockwise and there are no options to rotate or prevent rotation of the output. Ugh.
After some more digging, I found yet another tool, eps2pdf, which converts an EPS image to PDF – and happily accepts a rotation parameter. I simply downloaded the EPS tools package and copied the three files into /usr/bin and made them executable to run them. Et voila, I’ve got a 3-tool-pipeline for generating margin-less plots – see the resulting graphic below.
In the plot file:
set size ratio 0.6 set terminal postscript enhanced color set output 'frequency.tmp.eps'
My script (plot.sh) for generating the PDF output:
gnuplot $1.plt eps2eps $1.tmp.eps $1.eps eps2pdf -r -90 $1.eps rm $1.tmp.eps
Run the script with
sh plot.sh frequency
And here’s the resulting PDF – beautiful, non?
You must be logged in to post a comment.