MATLAB export figure to .png changes size after export

조회 수: 3 (최근 30일)
Fernon Ejikhoudt
Fernon Ejikhoudt 2018년 7월 28일
편집: Fernon Ejikhoudt 2018년 7월 29일
In my script I create about 30 figures which are automatically saved as MATLAB .fig and as .png. For my report I sometimes need to change the aspect ratio (instead of the standard 900x900 pixels, I want to have 1600x1000). That is why I save them as .fig as well. Once opening one of these figs I go to export setup and change the size in width and height in points. I press aplly and export as png. However once I look back at my figure it has suddenly become 1924x1007. I have no clue where this is coming from.
I hereby include my figure saving procedure, though I doubt this should have any effect:
amountFigures = findobj('type','figure');
for k = 1:length(amountFigures)
set(figure(k),'PaperPosition',[0 0 (900/300)/0.393701 (900/300)/0.393701]); %Sets a high quality output to the image
set(findobj(gcf,'type','axes'),'FontSize',14); %A bigger fontsize is needed for better readability
hline = findobj(gcf, 'type', 'line');
set(hline,'Linewidth',2);
temp = get(gca);
titel = temp.Title.String;
temp.Title.String = [];
savefig([titel,'.fig'])
print(gcf,'-dpng','-r300',[titel]); %Saves the figures with the titel name.
close(figure(k))
end
  댓글 수: 1
Fernon Ejikhoudt
Fernon Ejikhoudt 2018년 7월 29일
편집: Fernon Ejikhoudt 2018년 7월 29일
Soo, an update: if I would set it to centimeters and use 23.8 cm, it gives me exactly 900 pixels and 39.68 is 1500 pixels (1 pixel ~ 0.02645). This works, but it is still no excuse for the change in size when 'points' is selected instead of centimeters.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by