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.
MATLAB export figure to .png changes size after export
4 次查看(过去 30 天)
显示 更早的评论
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
回答(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!