How to save a figure that is larger then the screen?

30 ビュー (過去 30 日間)
Peter
Peter 2012 年 5 月 3 日
回答済み: Adam Danz 2025 年 12 月 8 日
Hello,
i'm trying to save a 53x53 cm sized figure to an .eps-file. This results in a file containing only the on screen visible part of the figure. I'm using the Save As Option of the figure's menubar.
Example-Code:
plot(1:50,1:50);
set(gca, 'units', 'centimeters');
set(gca, 'position', [3 3 53 53]);
Thx, Peter

採用された回答

Daniel Shub
Daniel Shub 2012 年 5 月 3 日
You cannot make figures larger than the screen size and if an axis does not fit in a figure, it gets truncated.
One possibility is to reduce the ScreenPixelsPerInch root property
set(0, 'ScreenPixelsPerInch', x)
where x is chosen so that MATLAB will think your monitor has both a width and height greater than or equal to 53 cm. You probably want to add some padding also for task and menu bars.
I have no idea how this will affect the output.
  2 件のコメント
Peter
Peter 2012 年 5 月 3 日
Didn't work fully.
I used x=40.
It helped me to fit the too large axes on the screen.
But if this are the sections of the figure:
[1] [2]
[3] [4]
The resulting .eps-file contained only:
[2]
[4]
But i could save it as a .fig-file that contained all the data.
Then i used export_fig.m from file-exchange, to export it as an .eps-file. And that did work. So my problem is solved.
Big thx
Tim Keiper
Tim Keiper 2020 年 4 月 22 日
This no longer works in Matlab 2019 - ScreenPixelsPerInch set to read only. is there a new solution using export_fig.m?

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

その他の回答 (3 件)

Demis John
Demis John 2013 年 11 月 27 日
編集済み: Demis John 2013 年 11 月 27 日
I Agree - see Jim's link above (skip the 2 spam posts & see Romesh's explanation) - enables one to save a figure of arbitrarily large size, regardless of size on screen.
You essentially use
set(gcf, 'PaperPosition', [0 0 20 20]) % can be bigger than screen
set(gcf, 'PaperSize', [20 20]) % Same, but for PDF output
& the print command:
print(gcf, 'MyFigure.png', '-dpng', '-r300' ); %save file as PNG w/ 300dpi
print(gcf, 'MyFigure.pdf', '-dpdf', '-r300' ); %save file as PDF w/ 300dpi
Units are inches by default; can change 'Units' property if desired.
  1 件のコメント
Daniel Shub
Daniel Shub 2013 年 11 月 27 日
I don't see how this works. If I want an axis that is exactly 53 cm x 53 cm what commands do I need to run?

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


Jim
Jim 2013 年 10 月 28 日
The answer is very elegant and uses the paper property size to print a figure of any size you want. Very helpful.

Adam Danz
Adam Danz 2025 年 12 月 8 日
Starting in R2025a, exportgraphics has options to specify the size of the exported figure. These features are exported in detail in the Graphics and App Building blog: https://blogs.mathworks.com/graphics-and-apps/2025/12/08/advanced-control-of-size-and-layout-of-exported-graphics/

Community Treasure Hunt

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

Start Hunting!

Translated by