How send to back patch objects in a graph?
84 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Modestas Sekreckis
il 27 Mag 2011
Commentato: ondrej
il 8 Giu 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
0 Commenti
Risposta accettata
Matt Fig
il 27 Mag 2011
Simply change the order of objects in the children property of the axes object.
set(gca,'children',flipud(get(gca,'children')))
Più risposte (2)
Patrick Kalita
il 27 Mag 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 Commento
Walter Roberson
il 27 Mag 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)."
Vedere anche
Categorie
Scopri di più su Polygons in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!