FIG2GLE v.0.6
FIG2GLE is a MatLAB/Octave script that takes the current figure and converts it into a LaTeX-compatible, thesis-quality PDF (or EPS). It does this by creating a text file with the datasets from the figure, then creating a text-based GLE file, which is used by the GLE command line to generate the figure.
FIG2GLE was literally written yesterday, with little testing. It's freely available and sneaky conspirators are encouraged to modify it to make it work better, or add functionality. Just send me your new version, so I can use it for my thesis.
Example:
I created a figure in MatLAB that shows two Lorentzian spectra, one centered at zero, one a 2 GHz. This is what MATLAB exports as a JPG.
Ugly, isn't it? Luckily, MatLAB supports other formats, including EPS 2 colour, which I exported here. That's much better! Good enough quality for a publication, certainly.
But there are limitations of this exported EPS... once created, we can't really edit the figure; for example, if we wanted to add a legend, or a title, or change the colours. There might be a utility that lets you do this, but I don't know how.
If you're writing a thesis, making small changes like this is almost guaranteed, which is why it's preferred to keep your figure data stored, then generate new figures as you need them.
Another small point that LaTeXheads are quick to notice: the fonts for the axis and the labels are rather ugly. We'd like to be able to change this, or at least make them similar to our LaTeX document.
FIG2GLE does these quite simply. It's a function, run with optional arguments. Type 'fig2gle' at your MatLAB/Octave command line, and the current figure gets stripped and translates into a .dat and .gle file, which are then used to create a PDF or EPS document.
See the final output!
Ex_laser.dat
Ex_laser.gle
Our final document: Ex_laser.pdf
I'm hardly an expert at either MatLAB or LaTeX, so feel free to modify and update the script to make it more complete. At the time of this writing, I've versioned it at v.0.5, since it's still quite limited and hasn't been rigourously tested
Download FIG2GLE.m
Update Jan 2009: fig2gle.m has been dissected, overhauled and
rewritten by Javier Kypuros. The new version does legend keys and
subplots, and looks to be written in a much more sustainable way than my
original bowl-of-porridge-hack.
Download
Javier's fig2gle.m code
Requirements:
-MatLAB OR Octave (if using Octave, you must have the io package, for dlmwrite.m. I'm too lazy to do it the other way...)
-GLE (available for Windows, OS/X and Linux. I compiled it from source in Kubuntu Hardy Heron with no problems yet)
-Set parameters in fig2gle.m to fit your system, eg. page size, colours. Set the FLAG_OCTAVE to 1, if you're using Octave, 0 if you're using MatLAB.
-a sense of wit, and appreciation of a good sandwich
Needed Developments:
-GLE doesn't render super- and sub-scripts very well
-Math symbols in labels
-Legend and text objects
-Arrows, lines and other annotations
-Subplots
-Support for more colours/linestyles
Development Log
v.0.5 - Initial version of fig2gle. Handles 3 colours, legends and b&W plots
v.0.6 - Updated to handle multiline plots of different lengths. Unfortunately, the only way I could think to do this was to generate one data file per line; a trace with 10 data sets will generate 10 data files.