Azzera filtri
Azzera filtri

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

24 visualizzazioni (ultimi 30 giorni)
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');

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 10 Feb 2011
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.

Più risposte (0)

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by