Why are the top and bottom parts of my MATLAB figure cropped when I use SAVEAS to save a figure to a PNG-file?

조회 수: 30 (최근 30일)
Why are the top and bottom parts of my MATLAB figure cropped when I use SAVEAS to save a figure to a PNG-file?
When I try to save my figure to a PNG-file using SAVEAS, the top and bottom parts of the image are cutoff. However, when I use SAVEAS to save my figure to a BMP-file, the figure appears just fine. If I use PRINT instead of SAVEAS, the cropping occurs for either file format. For example:
figure;
set(gcf,'position',[0 0 1000 800]);
axes('fontsize',28);
title('Title');
xlabel('X Axis');
saveas(gcf,'tmp','png');
saveas(gcf,'tmp','bmp');

채택된 답변

MathWorks Support Team
MathWorks Support Team 2011년 2월 10일
This is a bug in MATLAB 6.5 (R13) in the way that SAVEAS handles PNG-files. Our development staff is investigating this issue.
Currently, to work around this issue, try the following:
figure;
set(gcf,'position',[0 100 1000 800]);
axes('fontsize',28);
title('Title');
xlabel('X Axis');
f=getframe(gcf);
[X, map] = frame2im(f);
imwrite(X,'tmp.bmp');
imwrite(X,'tmp.png');
You will notice that the "Position" property has been changed to move the figure window above the Windows taskbar which is typically at the bottom of the screen. This is currently necessary to avoid including the taskbar in your saved image. Our development staff has been notified and is currently investigating this issue as well.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by