Think Big, We Do.
Rhode Island Seal

Generating Figures for Print in MATLAB

By David Chelidze

plot image format

When working in MATLAB one needs to know how to save figures as raster images or vector graphics. Before proceeding any further, make sure that you have already saved your figure into MATLAB’s FIG file. Now, you have two choices for saving files, one is using FILE menu on the figure window, and selecting “SAVE AS.” However, this has a big drawback: it will only save a figure in a default MATLAB size and proportions, which you may have altered using “PRINT PREVIEW.” This also does not allow you to use additional saving options.

The preferred option for saving would be the command prompt “print” command. For the detailed explanation of this command do:

>> help print

Raster images are suitable for printed posters and computer presentations (power point). For computer presentations, I recommend using a relatively new format when saving these files: PNG—portable network graphics—which only supports RGBcolor space. For print publications, i.e., posters, use TIFF—tagged immage file format (which supports both RGB and CMYK color spaces). In addition, I would recommend using “Print Preview” option in the File menu of the figure to make sure the image looks and is proportioned in a way you like it. The command I use for saving PNG files is:

>> print -dpng -r300 file_name

-dpng indicates that you want to use PNG format, and can be replaced with -dtiff, -dtiffnocompression, or djpeg<nn> for other convenient raster formats. Advantage of the PNG is that it can have transparent background and is small in size.
-r300 indicates the resolution of the image and should be big enough for the size you want to reproduce. In general for print you want it to be a minimum 150 dots per inch and for the screen 72 dots per inch (I believe this is the default). Sometimes I had to go as high as -r600 to have proper reproduction of details.
To crop PDF figure in Adobe Acrobat:

  1. Open the appropriate file in Acrobat
  2. Go to Document>Crop Pages…
  3. In “Margin Controls” select “Remove White Margins.”
  4. Save the file.

To crop PDF figure in Adobe Illustrator:

  1. Open the appropriate file in Illustrator
  2. Go to File>Document Setup
  3. Select “Edit Artboard”
  4. Adjust artboard by moving corners and save the file.

Vector graphics are best for print publications, since they can be scaled without loosing resolution—however, many plotters cannot handle them correctly, and raster (TIFF) would be a better choice there. The three formats that you may want to save in are actually a compound image formats that can handle some raster components too: -dill (for further editing in Adobe Illustrator), -deps2 (-depsc2) for encapsulated (color) postscript used in LaTeX publishing, and -dpdf for protable document format used in PDFLaTeX publishing (the latter two can also be edited in Adobe Illustrator). Command format is:

>> print -dpdf -cmyk file_name

where -cmyk forces the use of cmyk color space suitable for most color printers and plotters. You want to use default rgb color space for computer screen presentations. While EPS files are saved with appropriate bounding boxes for publication use, as of now PDFs (or ill) are saved into a default paper size files. Thus you need to used PDF tools (such as Adobe Acrobat Professional or Illustrator) to crop the white space around the figure or to adjust the artboard before using it in PDFLaTeX.

Setting Figure Aspect Ratio

This is on the aesthetic points of plotting in MATLAB. If I take a look at most of the plots that I come across, especially with multiple subplots, I find variety of inconsistent plot proportions. It is visually disturbing to see plots with disparate proportions in one paper/document. In literature there are two basic aesthetic proportions that are advocated:

  1. the default MATLAB proportion for a single plot is 4/3(in fact, its about 1.27~1.33:1); and
  2. golden ratio (1.618:1) proportions (the default for Mathematica plots).

Therefore, it is advisable to learn and use axis proportion commands. The simple way of doing this is through axis handle. Say you are generating several subplot and you want all of them to have the same proportions as the single plot you have generated previously. Here’s what you want to do:

% generating single plot
>> s1 = plot(x,y)
% this will have some default proportions ~1.3:1.
% To fix it to the desired proportion use this command:
>> pbaspect([1.33 1 1])
% this will fix aspect ration to 4/3. Now to subplots:
>> figure(2), for i = 1:4, subplot(2,2,i), pbaspect([1.33 1 1]), end
% this should generate four subplots whose aspect ratio will not change even if you resize the figure.

While 4/3 ratio is usually acceptable, many publishers requite figures in golden ration (which is claimed to be most aesthetically pleasing to the eye). In that case, just use pbaspect([1.618 1 1]). Note: golden ratio is actually an irrational number…

Copyright © 2020 University of Rhode Island.

The University of Rhode Island
Think Big, We Do.
A-ZDirectoryContact UsJump to top