How send to back patch objects in a graph?

92 ビュー (過去 30 日間)
Modestas Sekreckis
Modestas Sekreckis 2011 年 5 月 27 日
コメント済み: ondrej 2015 年 6 月 8 日
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

採用された回答

Matt Fig
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')))
  1 件のコメント
ondrej
ondrej 2015 年 6 月 8 日
u rock!

サインインしてコメントする。

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 5 月 27 日
Please see my Comment about opengl in this Answer

Patrick Kalita
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
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 ExchangePolygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by