Hello,
I am trying to save a matlab figure in PNG format, I wish to have a full screen size image. I have tried the following two scripts, in both cases the figure is visualized in full screen size, but the PNG file I get is smaller. Could anyone help me to fix this issue?
I thank you in advance. Giuseppe
figure('units','normalized','outerposition',[0 0 1 1])
plot([0,1], [0,1])
print('foos', '-dpng', '-r0');
or
figure; set(gcf, 'Position', get(0, 'Screensize'));
plot([0,1], [0,1])
print('foos', '-dpng', '-r0');

 채택된 답변

Jan
Jan 2017년 5월 16일

11 개 추천

FigH = figure('Position', get(0, 'Screensize'));
F = getframe(FigH);
imwrite(F.cdata, 'Foos.png', 'png')

댓글 수: 4

Giuseppe Papari
Giuseppe Papari 2017년 5월 16일
Thank you so much, now it works!!!
BTW, what was wrong in the code I made?
Jan
Jan 2017년 5월 16일
print does not use the screen resolution and position, but the PaperSize, PaperUnits and PaperPosition properties of the figure, because it is intentionally thought for printing on paper.
Mustafa Vardaroglu
Mustafa Vardaroglu 2019년 12월 10일
Thanks a lot!
Surama Biswas
Surama Biswas 2021년 3월 10일
How about if i want to save the image after imwrite?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sarwan ali
Sarwan ali 2019년 1월 24일

10 개 추천

To extend the answer from Jan, you can also use "saveas" command instead of imwrite
FigH = figure('Position', get(0, 'Screensize'));
saveas(FigH, 'Foos.png','png');

카테고리

도움말 센터File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

질문:

2017년 5월 16일

댓글:

2021년 3월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by