How send to back patch objects in a graph?
조회 수: 76 (최근 30일)
이전 댓글 표시
Hi, I draw a graphic http://img196.imageshack.us/img196/3923/matlaboklausimas3.png I use is this code:
a1=[1 150];
a2=[1 180];
a3=[1 200];
z1=[1 150];
xk=[50 100];
zk=[20 150];
kx = [xk(1,1) xk(1,2) xk(1,2) xk(1,1);];
kz = [zk(1,1) zk(1,1) zk(1,2) zk(1,2);];
figure(20) plot(a1,z1,a2,z1,a3,z1)
set(gca,'XDir','reverse')
xlabel('X'); ylabel('Z');
axis([0 MAX_X+1 0 MAX_Y+1])
patch(kx(1,:),kz(1,:),'y')
How I can sent to back patch objects. I need to show all the lines
댓글 수: 0
채택된 답변
Matt Fig
2011년 5월 27일
Simply change the order of objects in the children property of the axes object.
set(gca,'children',flipud(get(gca,'children')))
추가 답변 (2개)
Patrick Kalita
2011년 5월 27일
If this is going to be a strictly 2D scene (that is, you aren't planning on adding any 3D elements like a surface), then the best way to ensure the patch object is drawn behind the lines is to (1) set the axes DrawMode property to 'fast' and (2) draw the patch before the lines. Setting the DrawMode property to 'fast' ensures that the objects are drawn in the same order that they are added to the axes.
Here's a snippet based on your example:
a1=[1 150];
a2=[1 180];
a3=[1 200];
z1=[1 150];
xk=[50 100];
zk=[20 150];
kx = [xk(1,1) xk(1,2) xk(1,2) xk(1,1);];
kz = [zk(1,1) zk(1,1) zk(1,2) zk(1,2);];
figure(20);
a = axes('DrawMode', 'fast');
patch(kx(1,:),kz(1,:),'y');
hold on;
plot(a1,z1,a2,z1,a3,z1)
set(a,'XDir','reverse')
댓글 수: 1
Walter Roberson
2011년 5월 27일
Drawmode is defined for the painters renderer but not for other renders.
The documentation describing the OpenGL renderer indicates, "OpenGL and Zbuffer renderers display objects sorted in front to back order, as seen on the monitor, and lines always draw in front of faces when at the same location on the plane of the monitor. Painters sorts by child order (order specified)."
참고 항목
카테고리
Help Center 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!