matlab去除绘图白边

去除白边

set(gca,'LooseInset',get(gca,'TightInset'))

set(gca, 'LooseInset', [0,0,0,0]);

但发现有时直接选择图片充满窗口时,有一部分图的右侧边框会被覆盖到。这时可以调整一下以上两条命令的位置,把set(gca,'LooseInset',get(gca,'TightInset'))放在figure命令后。

figure
%set(gca, 'LooseInset', [0,0,0,0]);
set(gca,'LooseInset',get(gca,'TightInset'))
plot(linspace(0, 300, 38144), acc_1(:, 6)*g)
xlabel('Time(s)')
ylabel('Acceleration(m/s^2)')

  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

matlab调整绘图的边缘空白尺寸

matlab出图时边缘会有白边,为了插入文章后的美观,需要进行调整白边尺寸。

一种简单的方式是可以直接在figure窗口配置导出参数,但发现有时直接选择图片充满窗口时,有一部分图的边框会被覆盖到。此时,可通过下面的代码对上下左右的白边尺寸进行微调。

ax = gca;
outerpos = ax.OuterPosition; % [0, 0, 1, 1]

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];