default size figures with subplot

15 vues (au cours des 30 derniers jours)
Kamuran
Kamuran le 19 Mai 2015
Commenté : Kamuran le 20 Mai 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

Réponse acceptée

Joseph Cheng
Joseph Cheng le 19 Mai 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 commentaires
Joseph Cheng
Joseph Cheng le 19 Mai 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.
Kamuran
Kamuran le 20 Mai 2015
Thanks :)

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by