Descriptive Page Image Gnuplot to Adobe Illustrator Cleaner
Places
Oliver Dial
Ashoori Group
Physics
Simulations
Spectroscopy
Equipment
He3 System
Dil Fridge
AFM
Leitz µscope
Older Stuff
Nanowires
Etc.
Gnuplot-AI
Shape Grammars
File Submit
Protected

Gnuplot's postscript output is fantastically handy, especially in conjunction with Adobe Illustrator. Illustrator allows you to open the postscript files generated by gnuplot, and edit them, either to correct axis labels, add arrows and annotations, or generally turn them into production quality figures. However, there are a few deficencies in gnuplot's output, some of which are generic, and some of which are probably only important when using illustrator.

GPAI is a little script that cleans up some of the biggest problems with gnuplot's postscript output

GPAI is a script which should work on any computer with Gawk installed. It is released under the Gnu Public License.

Download and Usage

The current version of GPAI can be downloaded here

   Download gpai_1.0.tar.gz

Un-tar the file and copy gpai someplace on your path (/usr/local/bin might be a good choice). You'll need a copy of gawk (apt-get install gawk under Debian or sudo apt-get install gawk under Ubuntu) and run gpai by typing

gpai input_file > output_file

Where input_file and output_file are replaced by file names of your choice.

Benefits

  • Smaller postscript files (as much as 10x smaller for surface plots or high sample densities!)
  • Faster load times for postscript files
  • Each line in the plot is a single, contiguous path in Illustrator, making it easy to change linetypes and colors, or even delete paths.
  • Lines in the key are not joined to lines in the plot as a compound path, simplifying editing the key
  • With fewer line segments in the drawing, Illustrator is much more responsive and creates fewer spurrious "smart guide" hits.

Generic Problems Solved

  • When plotting analytic functions, gnuplot outputs a series of short lines that sample the function on regular intervals. While there's nothing wrong with that, it ends up putting a huge number of line segments into the postscript file, even when plotting "straight lines". GPAI looks for places where these short line segments can be combined into longer lines with no loss of accuracy, and does so, often drastically reducing the size of the output file.

Illustrator Specific Problems Solved

  • Gnuplot doesn't issue an endpath command when changing from drawing the key to drawing the curves, causing the line segment in the key to be joined to the line segment in the curve as a "compound path".
  • Gnuplot occasionally issues a move/stroke command (every hundred points or so) during the curves. This is presumably important for compatibility with some device somewhere, but it's annoying in Illustrator because it splits paths up into short chunks which need to be joined manually (or with some nice plugin like Rick Johnson's Concatenate). These also cause bizzare problems with corners on wide lines and discontinuities in dashed lines. GPAI removes these.

Outstanding Issues

  • GPAI can be slow on large plots (it's order n-squared in the length of line segments that get collapsed). Rewriting it in a language with faster arrays might help
  • If a curve is clipped (leaves and re-enters the page), it should probably have the different pieces of it joined as a compound path.
  • Documentation would be nice
  • There probably should be a copy of the GPL included with GPAI

Caveats and Support

There is no warranty of any kind with this software. It manipulates the postscript output of gnuplot on a very gross level, and will probably not work with the postscript output for all versions of gnuplot. If you find a postscript file generated by gnuplot that GPAI mangles, send it to me at odie@electron.mit.edu along with what version of gnuplot you're using, and if possible a gnuplot script for generating the problem, and I'll see if I can fix it for you.