Saving MATLAB Figures as PDFs: Issues & Solutions

In summary, the conversation discusses issues with saving MATLAB figures as PDFs and suggests using a startup.m file to improve the quality and resizing of figures. It also advises against using MATLAB's built-in save as PDF function.
  • #1
NoobixCube
155
0
Hey all,
after producing a fig. with matlab, I save it as a PDF. But upon opening the pdf it seems to cut the fig to a portrait page, when the figure is actually a landscape image. Any ideas?
For an idea of what's going on, see the attached file.
 

Attachments

  • pdfomg.pdf
    17.5 KB · Views: 354
Physics news on Phys.org
  • #2
Yeah don't ever use matlab's save as "pdf", it's terrible.
Two things if you are still going to do it this way:
-When you save as .pdf, the image will be produced according to the window size of your figure
-Look at your graph's, notice how they're rugged and "jaggedy"? That's a flaw of matlab.

I know you're attaching these figures in a document so here's something you should definitely do:
Go into matlab.
Create a new script file.
Place the following commands in it:

format long
format compact
set(0, 'defaultFigurePaperType', 'A4')
set(0, 'defaultFigurePaperUnits', 'centimeters')
set(0, 'defaultFigurePaperPositionMode', 'auto')

Save the file as startup.m and save in directory:
...\Matlab\Toolbox\Local\
Now everytime Matlab starts and you produce a figure, it will scale the window and any saved file to an A4 standard where you can fit upto 2 figures on a page. (save as EPS always, and convert to pdf).
 
  • #3


Hello, thank you for bringing this issue to our attention. It appears that there may be a formatting issue when saving MATLAB figures as PDFs. One possible solution could be to adjust the page orientation settings before saving the figure as a PDF. This can be done by going to the "File" menu, selecting "Page Setup", and then selecting the appropriate page orientation (landscape in this case). Another solution could be to adjust the size of the figure to fit within a portrait page before saving as a PDF. I would also recommend checking for any updates to the software or consulting with the MATLAB support team for further assistance. Thank you.
 

FAQ: Saving MATLAB Figures as PDFs: Issues & Solutions

1. Why is my MATLAB figure not saving as a PDF?

The most common reason for this issue is that the figure contains elements that are not supported by the PDF format, such as transparency or 3D objects. These elements need to be removed or flattened before the figure can be saved as a PDF.

2. How can I remove transparency from my MATLAB figure?

To remove transparency, you can use the alpha function in MATLAB to set the transparency value of each element to 1. Alternatively, you can use the flatten function to merge all transparent elements into a single image before saving as a PDF.

3. Can I save a MATLAB figure with 3D objects as a PDF?

No, the PDF format does not support 3D objects. If your figure contains 3D objects, you will need to either remove them or convert them to 2D images before saving as a PDF.

4. Why do my saved PDF figures have low resolution?

This can happen if the resolution of your figure is not set high enough. You can adjust the resolution by using the PrintSize option when saving as a PDF, or by manually setting the Resolution property of the figure.

5. How can I save a MATLAB figure with custom fonts as a PDF?

If you are using custom fonts in your figure, you will need to make sure that those fonts are embedded in the PDF file. This can be done by using the FontEmbedMode option when saving as a PDF, or by making sure that the fonts are installed on the computer where the PDF will be viewed.

Similar threads

Replies
1
Views
1K
Replies
7
Views
15K
Replies
5
Views
4K
Replies
4
Views
3K
Replies
1
Views
2K
Replies
12
Views
3K
Replies
1
Views
2K
Replies
4
Views
3K
Back
Top