How to reduce the borders around subplots in matlab? [duplicate]

爱⌒轻易说出口 提交于 2019-11-27 09:40:29

问题


Possible Duplicate:
MATLAB subplot margin

In matlab, an inordinate amount of space is wasted around subplots. For example, in this example:

t = 0:0.001:2*pi+0.001;
figure(2);
for i = 1 : 25;
    subplot(5,5,i);
    plot(t, sin(i*t));
    axis off
end

over 50% of the space on the figure is wasted as "blank" I'd like to shrink that blank space down, but have been unsuccessful to identify a mechanism to do so. Thoughts?

Thanks John


回答1:


The subaxis function on the File Exchange allows you to specify margins for subplots.

Example usage:

t = 0:0.001:2*pi+0.001;
figure(2);
for i = 1 : 25;
    subaxis(5,5,i, 'Spacing', 0.03, 'Padding', 0, 'Margin', 0);
    plot(t, sin(i*t));
    axis tight
    axis off
end




回答2:


You can position them yourself (or programatically) using

subplot('Position',[left bottom width height]);

By default, the coordinates are normalized. So a position of [0.1 0.1 0.5 0.5] will start at 10% of the way in from the lower left corner, and will have a width equal to half the figure width, and a height equal to half the figure height.

See the accepted answer for a built-in solution to margins and padding.




回答3:


Try to reduce the default values in the hidden axes LooseInsets property, as described in http://UndocumentedMatlab.com/blog/axes-looseinset-property/

For example:

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


来源:https://stackoverflow.com/questions/6685092/how-to-reduce-the-borders-around-subplots-in-matlab

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!