Stuart’s MATLAB Videos

Watch and Learn

Managing subplot layouts in MATLAB 2

Posted by Doug Hull,

Many people use subplot to layout axes, but do not know there is a second way of using it so that all the axes can be sized differently. Also, a method for having a common x-axis is shown.

2 CommentsOldest to Newest

Dan Dolan replied on : 1 of 2
Nice video Doug, though sometimes I find it easier to directly call axes with 'OuterPosition' settings than working out which elements of subplot each axes should span. One general complaint: adding a colorbar to one of your axes messes with the overall alignment, forcing you to tweak the 'Position' property of the other axes objects.
Kevin Holst replied on : 2 of 2
Doug, Nice short tutorial. I wasn't aware that you could do something like:
h(4) = subplot(6,1,4:6);
I would have expected:
h(4) = subplot(2,1,2);
For maybe 99% of the cases I would run into, both would work fine, but it's good to know both methods. Another thing that this figure likely will need is to link the x-axes between the 4 subplots in order to zoom properly, since there is one x-axis label for all 4 subplots.