How send to back patch objects in a graph?

76 visualizaciones (últimos 30 días)
Modestas Sekreckis
Modestas Sekreckis el 27 de Mayo de 2011
Comentada: ondrej el 8 de Jun. de 2015
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

Respuesta aceptada

Matt Fig
Matt Fig el 27 de Mayo de 2011
Simply change the order of objects in the children property of the axes object.
set(gca,'children',flipud(get(gca,'children')))

Más respuestas (2)

Walter Roberson
Walter Roberson el 27 de Mayo de 2011
Please see my Comment about opengl in this Answer

Patrick Kalita
Patrick Kalita el 27 de Mayo de 2011
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 comentario
Walter Roberson
Walter Roberson el 27 de Mayo de 2011
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)."

Iniciar sesión para comentar.

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by