How send to back patch objects in a graph?
80 次查看(过去 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!