如何在极坐标中制作箭袋图

Mic*_*ski 7 python matplotlib

如何在极坐标中制作箭袋图?我有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)
Run Code Online (Sandbox Code Playgroud)

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

tac*_*ell 6

它看起来像箭袋不为你做转换.您需要手动执行(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))
Run Code Online (Sandbox Code Playgroud)

图形