Azzera filtri
Azzera filtri

How do you indicate the order of plotted points in a polar plot?

4 visualizzazioni (ultimi 30 giorni)
I know that for cartesian coordinates you can use the quiver function to draw arrows to show the order of points. I was wondering if there was a similar way to do this with polar plots:
I made a polar plot from some data and then added the arrows I want in paint. It would be a lot nicer if I could just do this directly in matlab.
Thanks!
Here is an example of what I am trying to do except in cartesian:
x = rand(10,1);
y = rand(10,1);
dx = diff(x);
dy = diff(y);
plot(x,y,'ro');
hold on
quiver(x(1:end-1),y(1:end-1),dx,dy,0)

Risposta accettata

Star Strider
Star Strider il 22 Mar 2023
Unforutnately, quiiver and polaraxes don’t work together. The only alternative is to create your own polar axes as Cartessian axes, and then tweak until you get the desired result.
This should get you started —
p = linspace(0, 1, 25); % Function To Be Plotted
r = exp(-1.5*p);
a = p*2*pi;
rg = linspace(0, 2*pi, 13); % Angle Coordinate Definition
zv = zeros(size(rg));
cg = linspace(0, 2*pi, 400); % Radial Coordinate Definition
cx = ((0:0.2:1).'*cos(cg)).';
cy = ((0:0.2:1).'*sin(cg)).';
figure
plot([zv; cos(rg)], [zv; sin(rg)],'-k') % Plot Angle Vectors
hold on
plot(cx,cy,'-k') % Plot Radial Vectors
[x,y] = pol2cart(a,r); % Plot Functioon With 'quiver'
u = gradient(x);
v = gradient(y);
quiver(x, y, u, v, '-b')
hold off
axis('equal')
Ax = gca;
Ax.Visible = 'off';
text(cos(rg(1:end-1))*1.11-0.1, sin(rg(1:end-1))*1.1, compose('%d°',0:30:330))
text(cx(1,:),cy(30,:), compose('%.1g',0:0.2:1), 'Horiz','right', 'Vert','top')
Maybe some day this will be easiier.
.

Più risposte (0)

Categorie

Scopri di più su Polar Plots in Help Center e File Exchange

Tag

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by