如何在极坐标下制作箭头图

11

我如何在极坐标系下制作箭头图?我已经有了以r和theta为变量的数据。我已尝试过:

import numpy as np

radii = np.linspace(0.5,1,10)
thetas = np.linspace(0,2*np.pi,20)
theta, r = np.meshgrid(thetas, radii)

f = plt.figure()
ax = f.add_subplot(111, polar=True)
ax.quiver(theta, r, dr, dt)

其中dr和dt是r和theta方向上的数据向量。

1个回答

10

看起来 quiver 不会为你完成转换。 你需要手动进行 (r,t) -> (x,y) 的转换:

radii = np.linspace(0.5,1,10)
thetas = np.linspace(0,2*np.pi,20)
theta, r = np.meshgrid(thetas, radii)

dr = 1
dt = 1

f = plt.figure()
ax = f.add_subplot(111, polar=True)
ax.quiver(theta, r, dr * cos(theta) - dt * sin (theta), dr * sin(theta) + dt * cos(theta))

graph


你不应该写一个(r,φ) → (x,y)的转换吗? - Maciek D.
是的,看起来我把那个写反了。 - tacaswell

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接