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.

답변 (1개)

Doug Hull
Doug Hull 2014년 11월 18일

0 개 추천

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

댓글 수: 4

the cyclist
the cyclist 2014년 11월 18일
편집: the cyclist 2014년 11월 18일
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'))));
the cyclist
the cyclist 2014년 11월 19일
Yes, that seems to work. Thanks!
men8th
men8th 2023년 2월 8일
편집: men8th 2023년 2월 8일
An explicit version of the above command, which doesn't rely on casting a figure handle to double returning the figure number is:
set(groot,'Children',sort([get(groot,'Children').Number]))
This also uses groot to point to the graphics root object, rather than the magic number 0.
From reading the documentation, This will only find and re-order figures with visible handles. To work with all figures, you need to use findall.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2014년 11월 18일

편집:

2023년 2월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by