have a figure slide under another
이전 댓글 표시
Hi, I would like to have figure2 slide from behind figure 1 when I push a button. Unfortunately I was able to accoplish all that with exception of the sliding from behind. Each time I set the posiion it bring figure 2 to front and stays there. I know I can push figure 2 back behind figure 1 once I set the position however it does not look good or natural. Any ideas how to keep figure 2 behind the whole time? Thank you
figure 1
figure2('Visible','off')
figure(figure1)
for i = 1:65.2
set(figure2,'Position',[103.2+i 34.0769+10 62.8 15.6923])
end
채택된 답변
추가 답변 (2개)
Does this work?
% Example
f = figure; % create first figure
g = figure; % create second figure (appears in front of first)
figure(f) % bring first figure to front
I tried out your example, and calling the figure that should be "in front" like I did above inside the loop seemed to do the trick.
댓글 수: 6
Vincent I
2013년 6월 24일
figure1 = figure;
figure2 = figure;
p = get(figure1,'Position');
for i = 1:10:p(3)
set(figure2,'Position',[p(1)+i p(2)+10 p(3) p(4)]);
figure(figure1);
end
Here's my example code. What exactly about it doesn't work for you?
Vincent I
2013년 6월 24일
Your post did not specify whether you meant you were bringing figure1 to the front after each iteration or at the very end. I assumed the latter.
What exactly do you mean "it does not look good or natural"? Is the moving figure somehow choppy, or is there a flicker? I find that, when I run the above code, the "animation" is smooth. Adding short pauses after each iteration also helps to make it a bit more fluid.
Vincent I
2013년 6월 24일
Evan
2013년 6월 24일
Hmm, interesting. My way is certainly crude, though I don't experience any noticeable flicker due to the "bring to front." Perhaps Sean's solution will work for you.
Vincent I
2013년 6월 24일
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!