【问题标题】:How to make a quiver plot in polar coordinates如何在极坐标中制作颤抖图
【发布时间】:2018-10-10 20:52:14
【问题描述】:

如何在极坐标中绘制箭袋图?我有关于 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 方向的数据向量。

【问题讨论】:

    标签: python matplotlib


    【解决方案1】:

    看起来 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))
    

    【讨论】:

    • 不应该写(r,φ)→(x,y)转换吗?
    • 是的,看起来确实像我写的倒过来
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-03
    • 1970-01-01
    相关资源
    最近更新 更多