I am writing a paper currently using PDFTEX, and I make heavy use of MATLAB figures.

The problem is that when I make a MATLAB figure, I can adjust it to any size, before saving it. When I save it, I can save it as a .png, .tiff, .jpg, etc. Lastly, on LaTeX itself, I can adjust the size of the image there as well, (height, width, etc etc).

All those choices give me various quality images on my paper, so I am not sure what to do... do I have MATLAB images always large and then shrink them in LaTeX? Or make them small in MATLAB and expand them LaTeX? Is one image format better for display purposes in a PDF? What are best practices here?

Thank you.

  • 2
    I would recommend saving as PDF. PDF is a vector format, which means that, except for the spacing of the legend relative to the lines, the figure window size is irrelevant when you save it in terms of the resolution. Then you can set whatever size you will need in your LaTeX file. All that said, I'd really recommend you learn pgfplots. I am using/learning it now, and it makes for much better figures, and all you need are the data files!
    – darthbith
    Commented May 20, 2014 at 19:59
  • @darthbith Cool! Just to be clear, if I go to file->saveas on the MATLAB figure, and select '.pdf', is that the same as the pdf flag used if I did it manually ? Is there a difference between PDF as a document, and "PDF Color PDF file format" as per your first link? Thanks. Commented May 20, 2014 at 20:10
  • 1
  • I don't know if they do the same thing... There is no difference between the two formats though.
    – darthbith
    Commented May 20, 2014 at 21:23
  • Odd that nobody mentioned matlab2tikz. I find it problematic for all but the simplest figures, though. Commented May 11, 2017 at 18:25

3 Answers 3


My usual practice is to export MATLAB figures as .pdf files, because they are readily recognizable by PDFTEX and are rendered as vectorized images so resizing does not affect quality. The following is a nice MATLAB extension that works great for exporting figures as .pdf without the problem of exporting the image as a whole page:


It also has a nice documentation page: https://sites.google.com/site/oliverwoodford/software/export_fig

  • Hi, sorry, but does thsi ghostscript work for Win-7 OS's? ... I cant seem to get this guy's code working on here. Commented May 21, 2014 at 0:29

A bit late to the party here, but I've been putting a lot of MATLAB figures in a few papers I'm working on and have developed an effective routine...

Determine text width

Use the method from this answer to determine the \textwidth of your LaTeX document. You can extrapolate from here to print \textheight too.

Set MATLAB figure width

Set your MATLAB figure to this width:

set(1, 'units', 'centimeters', 'pos', [0 0 15 10])

The brackets contain: [x-position y-position width height]. I usually play around with the height value to find something that works for my plot, but a good rule of thumb is 1/4 to 1/3 of the text height.

Note that x-position and y-position don't really matter -- they define where the figure will appear on your screen, relative to the bottom left corner.

Set MATLAB margins and export

As @user3228896 mentioned, you can control the pdf margins from within MATLAB, but no extension is necessary. Just stick this after each figure:

% plot(somestuff);  
pos = get(figNum,'Position');
set(figNum,'PaperPositionMode','Auto','PaperUnits','centimeters','PaperSize',[pos(3), pos(4)])

If you've got multiple plots make sure to set a unique value for myfigure so they don't all overwrite each other.

All of this can be done in inches too.

LaTeX interpreter for plot labels in MATLAB

You can use LaTeX for MATLAB plot labels to keep variable names and such consistent.

It's also possible to change the font family, though personally I find the default MATLAB sans-serif font works well.

Place the figure

When you insert the figure, you can adjust it a bit using factors of \textwidth:

    \caption{This is the caption text}

Since you're using a pdf, a bit of stretching up or down won't make a difference in quality, so I usually just play with this a bit until it looks right.


The point is that Matlab saves figures with a different resolution and sometimes different tick marks than the ones shown on screen. At some point in your procedure, you will have to set, in Matlab, 'PaperPositionMode' to 'auto'. In this way, Matlab will save the figure at the size displayed on screen.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .