plot arrow in polarplot() (not cartesian axes)

24 visualizaciones (últimos 30 días)
Jack Supple
Jack Supple el 9 de Abr. de 2018
Comentada: Xiaoyu Zhao el 6 de En. de 2021
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...)

Respuesta aceptada

Jack Supple
Jack Supple el 10 de Abr. de 2018
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')

Más respuestas (0)

Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by