Change colors of arrows in quiver3

71 ビュー (過去 30 日間)
Tala
Tala 2021 年 4 月 27 日
編集済み: Scott MacKenzie 2021 年 4 月 30 日
Hi,
I used quiver3 to plot some wind measurements at three different heights. I would like to change the color for the bottom, middle and top arrows to red, green and blue respectively. I would be grateful if you can help me with that.
I only used quiver3 beacuse I knew the function. Please suggest other functions if they would a better suite for this purpose.
quiver3(x3d,y3d,z3d,cell2mat([Vx_NB_B Vx_NB_M Vx_NB_T]),cell2mat([Vy_NB_B Vy_NB_M Vy_NB_T]),zeros(1,90))
  1 件のコメント
Scott MacKenzie
Scott MacKenzie 2021 年 4 月 27 日
How about this:
h1 = quiver3( . . . ); % code for top arrows
h1.Color = 'r'; % red arrows
hold on;
axis([0 80 0 200 0 9]);
h2 = quiver3( . . . ); % code for middle arrows
h2.Color = 'g'; % green arrows
h3 = quiver3( . . . ); % code for bottom arrows
h3.Color = 'b'; % blue arrows

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

採用された回答

Scott MacKenzie
Scott MacKenzie 2021 年 4 月 30 日
編集済み: Scott MacKenzie 2021 年 4 月 30 日
Faraz's primary concern is controlling the color in each stratum of the plot. I think this is close to the answer sought:
n = 500;
bottomStratum = [10 20];
middleStratum = [40 60];
topStratum = [80 90];
x = randi(100, 1, n);
y = randi(100, 1, n);
z1 = randi(bottomStratum, 1, n);
z2 = randi(middleStratum, 1, n);
z3 = randi(topStratum, 1, n);
u = x .* rand(1, n);
v = y .* rand(1, n);
w1 = z1 .* rand(1, n);
w2 = z2 .* rand(1, n);
w3 = z3 .* rand(1, n);
% bottom arrows
quiver3(x, y, z1, u, v, w1, 'color', 'r');
hold on;
axis([0 100 0 100 0 100]);
% middle arrows
quiver3(x, y, z2, u, v, w2, 'color', 'g');
% top arrows
quiver3(x, y, z3, u, v, w3, 'color', 'b');

その他の回答 (1 件)

Pratheek Punchathody
Pratheek Punchathody 2021 年 4 月 30 日
You can use the following code as reference for changing the color of the arrows using the "Color property in quiver3()" function.
load wind %loading the data
X = x(5:10,20:25,6:10);
Y = y(5:10,20:25,6:10);
Z = z(5:10,20:25,6:10);
U = u(5:10,20:25,6:10);
V = v(5:10,20:25,6:10);
W = w(5:10,20:25,6:10);
quiver3(X,Y,Z,U,V,W,'color','r'); %'color' Name-Value pair will help to change the color of the arrow
axis equal
Below shows the output obtained from the above code.
Hope this helps..

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by