MATLAB Answers

the cyclist
0

Stacking order of figures

Asked by the cyclist
on 18 Nov 2014
Latest activity Commented on by the cyclist
on 19 Nov 2014
Suppose I create three figures
for ni = 1:3
figure
plot(rand(7))
drawnow
end
These will be drawn with Figure 1 on the bottom, Figure 2 in the middle, and Figure 3 on top, remaining viewable at the end.
How can change the stacking order? Prior to 2014b, one could sort the Children of the root object numerically, but I can't figure out how to do it in 2014b.

  0 Comments

Sign in to comment.

1 Answer

Answer by Doug Hull on 18 Nov 2014

Maybe I am misunderstanding the question:
close all
for ni = 1:3
figure
plot(rand(7))
drawnow
end
uistack(2,'top')
uistack(1,'top')

  3 Comments

You are not misunderstanding, but this tiny extension of your code does not correctly order the figures (in 2014b on latest Mac OS X):
rng('default')
NFIGURES = 4;
close all force
for nf = 1:NFIGURES
figure
plot(rand(7))
drawnow
end
for nf = NFIGURES-1:-1:1
uistack(nf,'top')
end
Bug?
FYI, how I did this formerly (and successfully) was
set(0,'Children',sort(get(0,'Children')));
Have you tried
set(0,'Children',sort(double(get(0,'Children'))));
Yes, that seems to work. Thanks!

Sign in to comment.