Why are the top and bottom parts of my MATLAB figure cropped when I use SAVEAS to save a figure to a PNG-file?
31 次查看(过去 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
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!