# Change colors of arrows in quiver3

55 visualizzazioni (ultimi 30 giorni)
Tala il 27 Apr 2021
Modificato: Scott MacKenzie il 30 Apr 2021
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 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Scott MacKenzie il 27 Apr 2021
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

Accedi per commentare.

### Risposta accettata

Scott MacKenzie il 30 Apr 2021
Modificato: Scott MacKenzie il 30 Apr 2021
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');
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Più risposte (1)

Pratheek Punchathody il 30 Apr 2021
You can use the following code as reference for changing the color of the arrows using the "Color property in quiver3()" function.
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..
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

R2020b

### Community Treasure Hunt

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

Start Hunting!

Translated by