Neater way to use subplots?

Recently, I have been using matlab for data analysis. When using subplots to compare multiple graphs at once, I have run into the problem wherein the plots look a bit sloppy when using 3 or more plots. Just for the problem's sake, I will use the variables:
a=1:5;
b=1:5;
c=1:10;
d=1:10;
e=5:15;
f=5:15;
The plots for these would be:
>> figure(1)
subplot(2,2,1)
plot(a,b)
hold on
subplot(2,2,2)
plot(c,d)
subplot(2,2,3.5)
plot(e,f)
I would like the bottom graph to be larger, potentially spanning the entire bottom of the display space. I thought changing the (m,n) variables in the subplot command would help, but it only leads to a jumbled up graph. Any advice here would be great

 Accepted Answer

Star Strider
Star Strider on 14 Feb 2015
It may be experiencing indigestion with the fractional reference. Consider using the 'Position' option instead.

3 Comments

Thanks! That gives me better control on the subplot.
My pleasure!
There are also many of posts on ‘Answers’ dealing with the intricacies of getting subplots to look just the way you want them to. I haven’t seen many recently, but I’ve answered a few in the past.
If wants the top two separate and the bottom to cover the positions of both lower as a single, then the answer is trivial as showed--
subplot(2,2,3:4)
This is documented and gives examples. Can also use contiguous elements vertically for the LH or RH sides--
subplot(2,2,[1 3])
is the two LH positions as one.

Sign in to comment.

More Answers (1)

dpb
dpb on 14 Feb 2015
Edited: dpb on 15 Feb 2015
See
doc subplot % illustrates exactly that kind of thing...
For your case, it's
subplot(2,2,1);
...
subplot(2,2,2);
...
subplot(2,2,3:4);
NB: it's the colon operator spanning the desired mushed-together subplots.

Asked:

on 14 Feb 2015

Edited:

dpb
on 15 Feb 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!