Wednesday, July 16, 2008

Steps for Creating Publication-Quality Figures Using Matlab 7 and PowerPoint (2003 edition)

As with the Excel method, my objective here is to be able to make changes
to the data or the presentation of the data without redoing huge amounts
of fiddly work or presenting figures which are no longer accurate
representations of the data. My particular goal is to never again find
myself shifting around the spacing of axis ticks and tick labels in a
graphics program by hand.

First, in Matlab:
- Get the figure looking as close to how I want it as possible. Since
Matlab figures are generated once and not linked to their data, it is best
to generate every aspect of the figure, down to fonts etc, from a script.
Ideally going all the way from the raw data spit out by your experiment
program to the nicely formatted end result. There's a command File ->
Generate M-file that could probably speed up the process of making these
scripts.

- Sizing in the ballpark of what you want in the end. Again the things
that are easily to do in powerpoint:
* Extra bits of text
* Extra graphics applied to it
* Any other tricky modifications or overlays
* Combining different figures (though if arranged in a strict grid, use of
subplot may be easier)

- Copy the figure to the clipboard in Enhanced Metafile format. Normally
Edit -> Copy Figure would do that automatically. But in most cases you
will not want to do that. As I discovered, although it is stored in a
vector format on the clipboard, the default command discards some of the
data in your figure. Specifically any more data than is needed to draw the
data at screen resolution. So if you have smoothly changing lines in your
figure that you want to print nicely, use instead this command:

print -dmeta -r600

It's exactly the same as doing Copy Figure, but only discards data below
the 600 dpi resolution. (note that exporting directly to an EMF file and
then importing seems to have this exact same problem)


Then in PowerPoint, follow most of the same steps as pasting an Excel
figure:
- Make a slideshow with 8 1/2 x 11-shaped slides, and dotted lines
indicated the maximum width for the figures

- For each figure, go to Paste Special, and choose Picture (Enhanced
Metafile). This seems to make a difference. Place the figure approximately
where it should go.

- Ungroup each (saying yes to converting to a microsoft office drawing
object), then ungroup again. For figures with multiple axes, you may have
to ungroup a third time.

- To resize the graph (while keeping all the axis ticks and tick labels in
place), select just the data area and the axis tick labels, not the axis
titles or legend, and group, then resize. I sometimes had to move around
the axis titles a bit, and for the matlab imports, sometimes the axis
tick labels.


Finally, on a test print two issues came up with both matlab and excel
generation of plots: both had lines making up the axes that were too thin,
so don't forget to change that (possibly in the source), and there was
also a hairline drawn around the entire figure (for some goddamn reason)
so make sure to ungroup and delete that box.

No comments: