필터 지우기
필터 지우기

Ordering graphics objects

조회 수: 2 (최근 30일)
Abed Alnaif
Abed Alnaif 2011년 9월 26일
Hi, I have a rectangular and a line graph, and I want to order the rectangle such that it is at the back of the figure (i.e. behind the line graph). How do I do this? I tried to use the set(gca,'Children',...) command, but it didn't work (i.e. the rectangle shows up on top of the graph, and hides the data). My operating system is Mac OS X, in case that matters. See the example code below:
function test_plot( )
figure;
p = plot(ones(5,1));
r = rectangle('Position',[0,0.9,1,0.2],'FaceColor','y');
set(gca,'Children',[p r])
end

채택된 답변

Grzegorz Knor
Grzegorz Knor 2011년 9월 26일
Command plot(x) is equivalent to plot(1:numel(x),x). In your example the rectangle is placed before the line on the x axis.
Plot line in this way:
p = plot(0:4,ones(5,1));
r = rectangle('Position',[0,0.9,1,0.2],'FaceColor','y');
set(gca,'Children',[p;r])
  댓글 수: 1
Abed Alnaif
Abed Alnaif 2011년 10월 6일
Sorry for the late response, but thanks -- this worked for me!

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

추가 답변 (1개)

Teja Muppirala
Teja Muppirala 2011년 9월 26일
The UISTACK command is used to order graphics objects.
help UISTACK

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by