Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get rid of the white space around matlab figure's pdf output

Tags:

pdf

matlab

I'd like to use PDF versions of my matlab plots in a LaTeX document. I'm saving the figures using the "saveas" command with the PDF option but I get huge white space around my plots in the pdf files. Is this normal? How can I get rid of it? Automatically, of course, since I have "a lot" of plots.

like image 468
mjbrown2 Avatar asked Sep 27 '10 07:09

mjbrown2


People also ask

How do I remove white space from a PDF?

1 Correct answer You can use the Crop Pages tool (under Tools - Organize Pages) to manually or automatically remove white space from the pages in your file. You can use the Crop Pages tool (under Tools - Organize Pages) to manually or automatically remove white space from the pages in your file.

How do you remove white space from a plot in MATLAB?

plot(..); smart_clean('NoWhiteSpace');

How do I stop MATLAB from displaying figures?

Accepted Answer To avoid showing figures in MATLAB you can start MATLAB using the noFigureWindows option. This option is not available on UNIX.

How do I export a graph from MATLAB?

Use the File > Export Setup dialog. Use Edit > Copy Figure to copy the figure's content to the system clipboard. For details, see Customize Figure Before Saving and Copy Figure to Clipboard from Edit Menu.


1 Answers

Exporting Figures for Publication is a good starting point. Instead of -deps use -dpdf for pdf output.

You can fix the bounding box issue using the code below.

set(gcf, 'PaperSize', [6.25 7.5]); set(gcf, 'PaperPositionMode', 'manual'); set(gcf, 'PaperPosition', [0 0 6.25 7.5]);  set(gcf, 'PaperUnits', 'inches'); set(gcf, 'PaperSize', [6.25 7.5]); set(gcf, 'PaperPositionMode', 'manual'); set(gcf, 'PaperPosition', [0 0 6.25 7.5]);  set(gcf, 'renderer', 'painters'); print(gcf, '-dpdf', 'my-figure.pdf'); print(gcf, '-dpng', 'my-figure.png'); print(gcf, '-depsc2', 'my-figure.eps'); 

You can read more about this on Tobin's article.

like image 84
zellus Avatar answered Sep 21 '22 01:09

zellus