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?
Padding = 'none'; t. TileSpacing = 'none'; Note that the last two commands get rid of all the space between the tiled plots.
It's possible to make subplots of different sizes by specifying a multiple-element vector for the grid position argument p in the syntax subplot(m,n,p) . Show activity on this post. You can add 4 axeses to the figure, and set the position of each axes: I = imread('cameraman.
subplot( m , n , p ) divides the current figure into an m -by- n grid and creates axes in the position specified by p . MATLAB® numbers subplot positions by row. The first subplot is the first column of the first row, the second subplot is the second column of the first row, and so on.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With