Displaying the order of objects on an axis

1 回表示 (過去 30 日間)
Bob Friday
Bob Friday 2015 年 3 月 5 日
コメント済み: Bob Friday 2015 年 3 月 9 日
I have a matrix that I am making a surface plot of and then trying to overlay a rectangle on top of it. I can not get the rectangle to be displayed on top of the surface.
figure(6)
h1= surface(M)
h2= rectangle(0,0,3,3,'Facecolor','r')
% I have tried to flip the children objects of the current axes but they did not work. I also tried uistack
% Is there something about a surface object that prevents anything from being rendered on top of it?
set(gca,'children',flipud(get(gca,'children')))
  1 件のコメント
Adam
Adam 2015 年 3 月 5 日
Are you sure the rectangle is present on the axes and within the axis limits that you set rather than somewhere off the axes?

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

採用された回答

Chris McComb
Chris McComb 2015 年 3 月 5 日
編集済み: Chris McComb 2015 年 3 月 5 日
You're having this problem because the rectangle command draws the object in the xy plane, with z=0. Therefore, since I'm guessing your surface has z > 0, the rectangle necessarily falls underneath it.
What if you did something like this?
% Plot surface
h1 = surface(M);
% Max height in surface
max_surf = max(M(:));
% Make a patch instead of rectangle
h2 = patch([0 3 3 0], [0 0 3 3], max_surf*ones(1,4), 'r');
  1 件のコメント
Bob Friday
Bob Friday 2015 年 3 月 9 日
Thanks, this makes sense and works great!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by