matlab 保存图片时减少左右两侧的空白区域

matlab绘图时,生成的图片两侧会出现大面积空白区域,在论文中排版时会影响整体的比例,格式排版以及图片清晰度都大打折扣,参考以下代码可以解决:

plot(peaks)
title('Plot of Peaks Function')
ax = gca;
outerpos = ax.OuterPosition;
ti = ax.TightInset; 
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) - ti(1) - ti(3);
ax_height = outerpos(4) - ti(2) - ti(4);
ax.Position = [left bottom ax_width ax_height];

当想对左右两侧的距离进行调整时,可以通过调节left ,bottom,ax_width ,ax_height的值来控制,例如可以通过+ti(num)或者-ti(num)手动调节。

原创文章 62 获赞 133 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_43142797/article/details/105058476