How to reduce borders around subplots in Matlab?

Possible duplicate:
MATLAB to fit the subtitle

In Matlab, an excessive amount of space is lost in the calculations. 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 

Example of wasted white space in subplots

more than 50% of the space in the picture is lost as "empty". I would like to reduce this empty space, but I could not determine the mechanism for this. Thoughts?

Thanks, John

+42
matlab subplot
Jul 13 2018-11-11T00:
source share
3 answers

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

Usage example:

 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 

enter image description here

+45
Jul 13 2018-11-11T00:
source share
β€” -

You can place them yourself (or programmatically) using

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

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

See accepted answer for inline solution for fields and padding.

+6
Jul 13 2018-11-21T00:
source share

Try decreasing the default values ​​in the hidden axis properties of LooseInsets , as described at http://UndocumentedMatlab.com/blog/axes-looseinset-property/

For example:

 set(gca, 'LooseInset', get(gca,'TightInset')) 
+4
Jul 14 2018-11-11T00:
source share



All Articles