Page 1 of 5 Exporting Figures for Publication by Ben Hinkle This article describes how to turn figures into publication-ready Encapsulated Postscript (EPS) files using a new MATLAB script called exportfig.m. In the past, getting your plots and graphs into journal articles and professional publications was time consuming and tedious. Generally, what looked good on the screen would often look bad on paper. Exportfig.m was designed to help users specify four key properties of an exported figure: size, color, line widths and font sizes. The following table summarizes the typical problems you might encounter with these properties when exporting. Property Size Color Line widths Font sizes Typical problem when exporting Exported plots are typically too large and need to be scaled down in the document Exported plots typically should be in black and white, grayscale or the CMYK color space Lines in exported plots typically are too thin Text in exported plots is typically the wrong size By using exportfig.m you can avoid these problems with ease. 2003 Issues January 2002 Issues November July May January 2001 Issues November June 2000 Issues December June Archived Articles 1999-1998 Subscribe Now Before we illustrate the use of exportfig.m, let's first plot a sin-wave. Launch MATLAB and execute x=0:.1:20; y=sin(x); plot(x,y); On the screen the plot looks like
Page 2 of 5 Adjust the axis bounds and add a grid with the commands axis([0 20-2 2]); grid on; and adjust the x-y ratio by resizing the window so that the plot looks like Let's use this plot for our publication-ready document. Without using exportfig.m, you would
Page 3 of 5 attempt to export the plot with the command print -deps pic1.eps and include the file "pic1.eps" into our document: Note that we are exporting to an EPS format. We could choose other formats, but EPS is the most common format to include in publication-quality documents. One of the first problems you notice with the above picture is that the aspect ratio is not as it looks on the screen. The plot's aspect ratio is the ratio of the width to the height. When exporting or printing, it is very common to want the exported plot to have the same aspect ratio as the plot on the screen. To fix the aspect ratio of the exported plot we first try to resize the plot in the document:
Page 4 of 5 But now the fonts are unreadable and the linewidths are very thin, though it might not be visible on the screen. Normally to fix this problem we would try setting the PaperPosition property of the figure before exporting as follows set(gcf, 'PaperPosition', [0 0 6 3]); print -deps pic2.eps and export the figure again into the document: As you can see, the fonts look much better, but the aspect ratio is still not quite correct. We can either guess again or compute it exactly from the screen position of the figure. But we would still not have control over the font sizes unless we explicitly set the font sizes of all text objects. Suppose we wanted all our font sizes to be 8 points when we export. We would have to remember the old font sizes, set the new sizes to 8 points, export and set the old values back. These sorts of tedious transformations and computations are exactly what exportfig.m does for you. To export the figure with a width of 6 inches, an aspect ratio the same as on-screen, and text objects with a fixed fontsize of 8 points, we execute the following command exportfig(gcf,'pic3.eps', 'width',6, 'fontmode','fixed', 'fontsize',8);
Page 5 of 5 Exportfig.m requires two parameters followed by a list of optional parameters. The first parameter is the handle to the figure to export. In the example above we are exporting the current figure, so we pass it the result of the get-current -figure command gcf. The second parameter is the name of the file to create. Exportfig can only produce output to a file. After the file parameter there are any number of optional parameter-value pairs. In the example above we passed three optional parameters, width, fontmode and fontsize with corresponding values. For more details about the capabilities of exportfig.m, type help exportfig to read the script?s documentation. News & Notes I Using MathWorks Products For... I MATLAB Based Books I Third-Party Products The MathWorks, Inc. Trademarks Privacy Policy