How do you indicate the order of plotted points in a polar plot?
조회 수: 8 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
채택된 답변
Star Strider
2023년 3월 22일
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.
.
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Polar Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!