Clear Filters
Clear Filters

default size figures with subplot

6 views (last 30 days)
Kamuran
Kamuran on 19 May 2015
Commented: Kamuran on 20 May 2015
I would like to combine couple or three figures into a single window but when I use subplot(2,1,1) and subplot(2,1,2) I get two long ones or subplot(1,2,1) and subplot(1,2,2) I get two tall ones. I just want two figures side by side with their default size.
Is that possible? if so, how ? :D
Thanks

Accepted Answer

Joseph Cheng
Joseph Cheng on 19 May 2015
yeah very simple.
hfig = figure;
pos = get(hfig,'position')
set(hfig,'position',pos.*[.5 1 2 1])
subplot(1,2,1),plot(randi(10,10,2))
subplot(1,2,2),plot(randi(10,10,2))
  2 Comments
Joseph Cheng
Joseph Cheng on 19 May 2015
well some additional playing around with it like
numplots = 4;
hfig = figure;
pos = get(hfig,'position')
set(hfig,'position',pos.*[0 1 numplots 1])
for ind = 1:numplots
subplot(1,numplots,ind),plot(randi(10,10,2))
end
does show there is some width modifications to the width of each axes, especially the more you put in. However the heights are the same. You can play around with the set() command for both the figure handle and axes handles to change their positioning if this slight change from the default size is an issue.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!