Sunday, September 25, 2011

Getting a high quality eps from your data

In all these years plotting data, I have tried many methods. The one I am most satisfied with is gnuplot. This free program can generate anything one has ever dream of from data. In the past, I used to have basic scripts for my favourite types of graphs; problem is, I'm not that patient any more. Still, I'm not ready to pay the big bucks needed to buy a fancy point and click plotting software and, above all, I'm not interested in illegal software.

This is my situation I usually generate my final data from FORTRAN. Usually, universities and research centres provide Matlab or Mathematica licences for us. I have tried doing figures with Matlab, but I found it quite primitive and, typically, I ended up investing as much time as it took to modify one of my old gnuplot scripts. So, I started using Mathematica to load my data from text files and generate my figures.

Important things to have in mind:
  • A typical one column figure has a size of 3 3/8 inches; say Phys. Rev., J. Opt. Soc. Am. or J. Phys. journals.
  • Typical figure sizes are one, one and a half, and two columns.
  • Usually, journals ask for high resolution graphics, say 300, 600 or 1200dpi.
Things to remember when preparing figures in Mathematica:
  • Standard image resolution value is 72dpi. One can set this to any value by using the command ImageResolution -> 300, for example.
  • If you are saving in svg file format resolution doesn't matter at all but for determining the size of the image. 
  • Always set your image size according to the resolution you are using, ImageSize->{(3+3/8)*300, Automatic}, for example.
Now, the simplest way to produce a figure is just exporting your figure to eps with the command Export["FigureName.eps", PlotName, ImageResolution->300]. Sometimes this is the best and fastest way to produce an eps. Always keep your fonts around the 12pt size. Do not mind how the image looks in the notebook, always check the final eps to see the figure in its real scale.

For those times when the result is crappy, I would export the figure to svg with the command Export["FigureName.svg", PlotName], for example. Then, I would modify the axis labels, legends, and other text in the figure with Inkscape. Inkscape is free, light, and easy to use and can save your graphics to eps format; it can also generate pure latex or eps+latex output. In the case that the text in the figure is formulas, I would use psfrag to replace dummy strings inserted with Inkscape.

Warning: As of today, if  you use psfrag, download Inkscape v0.46 and do not forget to de-select the convert text to path option in the dialogue for save as eps. The point behind using Inkscape v0.46 is that this is the last version that doesn't use Cairo to convert to eps and still writes text as text in the eps.

Edit: Janus told me today about a plugin for Inkscape that renders latex input into a graphic layer, it is called textext. Thing is, it works almost immediatly with Inkscape v0.46 and delivers wonderful results but I haven't been able to make it work with v0.49 so far. Nevertheless, good bye psfrag!

No comments:

Post a Comment