如何在极坐标中绘制箭袋图 [英] How to make a quiver plot in polar coordinates
本文介绍了如何在极坐标中绘制箭袋图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在极坐标中绘制箭袋图?我有关于r和theta的数据.我尝试过:
How do I make a quiver plot in polar coordinates? I have data in terms of r and theta. I've tried:
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方向上的数据向量.
where dr and dt are vectors of data in the r and theta directions.
推荐答案
看起来 quiver 不会为你做转换.您需要手动进行 (r,t) -> (x,y) 转换:
It looks like quiver does not do the conversion for you. You need to do the (r,t) -> (x,y) conversion by hand:
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))
这篇关于如何在极坐标中绘制箭袋图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文