フィルターのクリア

How to avoid objects from function "arrow3" to be plotted on top?

4 ビュー (過去 30 日間)
Orjan Kristensen
Orjan Kristensen 2023 年 12 月 6 日
コメント済み: Orjan Kristensen 2023 年 12 月 12 日
Hi! When using the Matlab function "arrow3", the resulting objects always come on top, no mather what I do. In the script below I want the blue and green marker on top of the red arrows. Is there anything I can do to achieve this? Thank you!
x1 = 0; x2 = 2; xs = 0.2;
y1 = 0; y2 = 6; ys = 0.5;
[x,y] = meshgrid(x1:xs:x2,y1:ys:y2);
dy = y; dx = ones(size(dy));
L = sqrt(1+dy.^2);
dy = dy./L; dx = dx./L;
p1 = [x(:) y(:)];
figure(1); clf;
arrow3(p1,p1+0.001*[dx(:),dy(:)],'r',0.5,2);
hold on
plot(1,2,'b.','Markersize',100)
plot(1,3,'g.','Markersize',100)
h=get(gca,'Children');
set(gca,'Children',flipud(h))
  2 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 12 月 6 日
Which arrow3 function are you using?
Orjan Kristensen
Orjan Kristensen 2023 年 12 月 6 日
編集済み: Orjan Kristensen 2023 年 12 月 6 日

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

採用された回答

Yash
Yash 2023 年 12 月 12 日
Hi Orjan,
I understand that you want to bring the blue and green marker on top of the red arrows. To do so you must set the “SortMethod” property of the “axes” from “depth” to “childorder”. This ensures that an object which is near the beginning of the “Children” list always covers an object which is later in the “Children” list.
Here is the updated code:
x1 = 0; x2 = 2; xs = 0.2;
y1 = 0; y2 = 6; ys = 0.5;
[x,y] = meshgrid(x1:xs:x2,y1:ys:y2);
dy = y; dx = ones(size(dy));
L = sqrt(1+dy.^2);
dy = dy./L; dx = dx./L;
p1 = [x(:) y(:)];
figure(1); clf;
arrow3(p1,p1+0.001*[dx(:),dy(:)],'r',0.5,2);
hold on
plot(1,2,'b.','Markersize',100)
plot(1,3,'g.','Markersize',100)
ax = gca;
ax.SortMethod = "childorder";
Refer here for more information:
I hope this helps!
  1 件のコメント
Orjan Kristensen
Orjan Kristensen 2023 年 12 月 12 日
Hi Yash.
This helps a lot, your method works perfectly, thank you so much! Also many thanks for the additional links, lots of useful reading here.
Best regards, Orjan.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by