plot arrow in polarplot() (not cartesian axes)

25 ビュー (過去 30 日間)
Jack Supple
Jack Supple 2018 年 4 月 9 日
コメント済み: Xiaoyu Zhao 2021 年 1 月 6 日
I need help to draw an arrow to a polar plot (e.g. to indicate resultant vector).
I am using the new polarplot() function as opposed to the old polar() or polarhistogram() functions. Thus I cannot (to my knowledge) use functions like quiver because this would be plotted onto cartesian axes (the polarplot() function, unlike polar(), actually uses polar axes, and you can't mix up cartesian and polar child axes, as far as I know).
As far as I can see, possible solutions would be:
1. simulate an arrow by calculating and drawing an arrow shape from lots of little lines using the polarplot() function, or
2. somehow merging cartesian and polar children plots onto the same figure (if this is possible) to make use of older arrow functions (e.g. quiver or compass).
This post seeks any better suggestions, and/or solutions to the above.
Thanks!
N.B. The choice to use the polarplot() function was based on better control of axis appearance (which you don't seem to get with polar() function), and better control of histogram bar aesthetics (which you don't seem to get with polarhistogram() function...)

採用された回答

Jack Supple
Jack Supple 2018 年 4 月 10 日
I ended up using method 1 in the question (1. simulate an arrow by calculating and drawing an arrow shape from lots of little lines using the polarplot() function). It seems to work alright, I'm sure there must be better methods. Posting code for others
polar plot arrow
%%%Data %%%%
resultant_direction = rand(1)*2*pi;
resultant_length = 0.5 + (1-0.5).*rand(1);
%%%%arrow head %%%%
arrowhead_length = resultant_length/15; % arrow head length relative to resultant_length
num_arrowlines = 100;
arrowhead_angle = deg2rad(30); % degrees
%%%%arrow tip coordinates %%%%
t1 = repmat(resultant_direction,1,num_arrowlines);
r1 = repmat(resultant_length,1,num_arrowlines);
%%%%arrow base coordinates %%%%
b = arrowhead_length.*tan(linspace(0,arrowhead_angle,num_arrowlines/2));
theta = atan(b./(resultant_length-arrowhead_length));
pre_t2 = [theta, -theta];
r2 = (resultant_length-arrowhead_length)./cos(pre_t2);
t2 = t1(1)+pre_t2;
%%%%plot %%%%
figure(1)
polarplot([t1(1) t1(1)],[0 r1(1)-0.9*arrowhead_length],'r','linewidth',3)
hold on
polarplot([t1; t2],[r1; r2],'r')
  1 件のコメント
Xiaoyu Zhao
Xiaoyu Zhao 2021 年 1 月 6 日
Well done and thanks for your solution!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by