Saving MATLAB figures as PDF with quality 300 DPI, centered
Asked Answered
B

2

8

I want to save a MATLAB figure as PDF, with quality 300 DPI, and centered.

So far I managed to save it, but the image appears cropped. I changed the page type to A3 and kind of solves the problem, but I am looking for something more elegant. I am doing it from the GUI, but maybe from the command line is easier in MATLAB.

Is there any package or script that makes this (fundamental task for publications and papers) a bit easier?

Bombardon answered 18/7, 2012 at 13:36 Comment(0)
K
4

Try using the following command:

print -painters -dpdf -r300 test.pdf

You will, of course, already have to have a file named test.pdf in the current directory.

Some notes on the -commands as well.

  • -painters: this specifies the use of the painters alogrithm for the exporting.
  • -dpdf: specifies a vector image, specially a pdf in this case. This is through Ghostscript.
  • -r300: specifies a 300 dpi resolution. -r400 would be 400 dpi and so on.

On an off note. I tend to just save the figure as a high DPI tiff image and import that tiff into another program where I actually assemble my figure(s) for the paper. I tend to lean towards CorelDraw personally.

Kassia answered 18/7, 2012 at 14:34 Comment(1)
Oh and it almost slipped my mind. You might have to set paper position, paper position mode and paper orientation prior to printing if you end up not getting a centered image and such. This would also allow you to format it to a greater extent if so desired.Kassia
C
2

I would recommend to check the exportfig package

exportfig(gcf, path_to_file, 'format','pdf','Resolution', 300 )

also, you can check fig package, which is nice to call before the exportfig:

figure
plot(x,y)
fig
exportfig(gcf, path_to_file, 'format','pdf','Resolution', 300 )    
Courthouse answered 11/11, 2014 at 9:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.