Sizing issues when exporting figures with exportgraphics on MacBook Pro 14" (Sonoma)

19 ビュー (過去 30 日間)
Daniel
Daniel 2024 年 6 月 26 日
回答済み: Eneru Y 2025 年 1 月 4 日
I'm having issues exporting figures to a certain size in PDF format.
I'm using a MBP 14" running macOS Sonoma, and MATLAB R2024a, Update 4 with the New Desktop for MATLAB (Beta), but the error is the same in the standard desktop. The fact that MATLAB uses a standard DPI size for macOS of 72 confuses me, but I assume that there is some upscaling going on, since my screen is 3024 x 1964 but MATLAB's ScreenSize property is only 1512x982.
However, when trying to display an image with a width of 20cm, the output figure, as well as the exported PDF is only 8.6cm wide.
width = 20;
height = 7.25;
set(groot, "defaultTextInterpreter", "latex");
set(groot, "defaultLegendInterpreter", "latex");
set(groot, "defaultAxesTickLabelInterpreter", "latex");
set(groot, "defaultFigureUnits", "centimeters");
set(groot, "defaultFigurePosition", [2, 2, width, height]);
set(groot, "defaultAxesFontSize", 11);
set(groot, "defaultLegendFontSize", 11);
set(groot, "defaultLineLineWidth", 1.25);
set(groot, "defaultStemLineWidth", 1.25);
After this, I create a figure with the figure command. To finally save the image, I use:
exportgraphics(fig, path, "ContentType", "vector");
Is this a Bug on macOS on newer machines?
  2 件のコメント
Bastian Lehnert
Bastian Lehnert 2024 年 9 月 16 日
I have the same issue with my mac. When exporting with an image width of 113 mm the pdf is 60.8 mm.
I checked the properties of the figure and the and Position(3) is 113 mm (also checked the unit).
Bastian Lehnert
Bastian Lehnert 2024 年 11 月 22 日
移動済み: Walter Roberson 2024 年 11 月 22 日
Same issue for me. Font size and everything is correct but the overall plot size is wrong. When running on windows, no issues

サインインしてコメントする。

回答 (2 件)

Divyanshu
Divyanshu 2024 年 7 月 5 日
編集済み: Divyanshu 2024 年 7 月 5 日
Hi Daniel,
I tried to reproduce the issue with my MAC but was getting the pdf as expected and did not encounter the issue.
However, as a workaround you can try to use either 'print' or 'saveas' function to export figure as a pdf, instead of 'exportgraphics'.
Please refer the following documentation links for more details:
And for the issue you are facing with 'exportgraphics', I would suggest to reach out to MathWorks Support:
Hope it helps!
  1 件のコメント
Daniel
Daniel 2024 年 7 月 10 日
編集済み: Daniel 2024 年 7 月 10 日
@Divyanshu But does it also display the figure on the desktop in the correct size?

サインインしてコメントする。


Eneru Y
Eneru Y 2025 年 1 月 4 日
I have the same problem on Windows. No control over size and font in vector mode. The best solution for me is still hgexport(). Perfect vector export, with correct size and font.

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by