How to change the color of only some arrows using quiver?

12 ビュー (過去 30 日間)
Marcos Ortensi
Marcos Ortensi 2021 年 7 月 29 日
コメント済み: Bjorn Gustavsson 2021 年 7 月 29 日
Hi everyone,
I would like to know if it is possible to change the color of only some of the arrows using quiver.
I tried to selected the data that I want with different color and plot a second quiver plot. Something like that:
figure
q1 = quiver(x,y,u,v)
hold on
q2 = quive(x(color2),y(color2),u(color2),v(color2))
The problem is that the size of the arrow of both plots doesnt match, although u and v are the same. Here is an example. We can see that the blue arrows are bigger than the magenta ones.
I suppose that is a problem in the function, related to the scale of the arrows. When the data for both quivers are the same, the problem does not happen.
I have tried to zero or NaN the data of the second quiver, instead of select with a filter, but it didnt solve the problem.
I am wonder if anyone have already the same problem and could help me.
Thank you!

採用された回答

Bjorn Gustavsson
Bjorn Gustavsson 2021 年 7 月 29 日
From the help of quiver:
quiver(U,V,S) or quiver(X,Y,U,V,S) automatically scales the
arrows to fit within the grid and then stretches them by S. Use
S=0 to plot the arrows without the automatic scaling.
So if you try to set S to something specified you might avoid the different scalings of your arrows. You might also try the different arrow-functions on the file-exchange which might give you more detailed controll over the arrows. See for example: arrow and arrow3 (they have a different set of the input arguments but that is manageable).
HTH
  2 件のコメント
Marcos Ortensi
Marcos Ortensi 2021 年 7 月 29 日
You are right!
I thought that seting S=0 would make all the vector's size equals to 1, but it only use the same unit of the axis.
Now I can set S=0 and add a scale manually multiplying my u and v.
Thank you very much!
Bjorn Gustavsson
Bjorn Gustavsson 2021 年 7 月 29 日
Glad that it helped.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by