Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving MATLAB figures as PDF with quality 300 DPI, centered

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?

like image 931
Larra Artea Avatar asked Jul 18 '12 13:07

Larra Artea


People also ask

How do I save 300 dpi in MATLAB?

To save a figure as an image at a specific resolution, call the exportgraphics function, and specify the 'Resolution' name-value pair argument. By default, images are saved at 150 dots per inch (DPI). For example, create a bar chart and get the current figure. Then save the figure as a 300-DPI PNG file.

How do I export high quality figures in MATLAB?

To get a high-resolution image from MATLAB, you may use the "copy figure" option. In your Matlab figure, go to the "Edit" option, select "Copy Figure", then paste it in MS word file using "crtl+v". If you want to use the figure in latex, then save the figure in the ". eps" format.

How do you change the DPI in MATLAB?

If it is only a single figure, use the GUI of the export-setup. File > Export Setup ... > Rendering > Resolution (dpi) + don't forget to click Apply to Figure.

Can you save a MATLAB plot as a JPEG image?

Save Plots InteractivelyThe export button supports three image formats (PNG, JPEG, and TIFF), as well as PDF files, which can contain images or vector graphics, depending on the content in the axes.


2 Answers

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.

like image 66
Ben A. Avatar answered Nov 15 '22 18:11

Ben A.


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 )    
like image 31
Dima Lituiev Avatar answered Nov 15 '22 17:11

Dima Lituiev