【问题标题】:PolarColor map plot of grid data in PythonPython中网格数据的PolarColor地图图
【发布时间】:2017-02-18 03:02:53
【问题描述】:

我想绘制网格数据的颜色图,以极坐标形式网格。在数据中,r 的范围是 1 到 2,theta 的范围是 0 到 360。我想要这样的地图:

我是这样设计的

#x1 of shape(12,)
#y1 0f shape(36,1)
#z of shape(36,12)
fig=plt.figure()  
ax=fig.add_subplot(111) #Output Figure 1
#ax=fig.add_subplot(111,polar='True') #Output Figure 2
ax=fig.add_subplot(111)
ax.pcolor(y1,x1,z)
plt.show()

输出:

知道如何绘制上图吗?我还尝试将 r、theta 转换为 x、y,然后我得到了 r

【问题讨论】:

    标签: python r matlab matplotlib


    【解决方案1】:

    正如here 指出的那样,pcolormesh() 对此很有用。

    import matplotlib.pyplot as plt
    import numpy as np
    
    theta = np.linspace(0, 2*np.pi, 36)
    r = np.linspace(1, 2, 12)
    
    R, THETA = np.meshgrid(r, theta)
    Z = np.sin(THETA) * R
    
    plt.subplot(111, projection='polar')
    plt.pcolormesh(THETA, R, Z)
    plt.gca().set_rmin(0.0)
    
    plt.show()
    

    output figure

    【讨论】:

    • 谢谢兄弟!我也在做同样的事情,现在我检查了我的数据,我的数据有错误
    • 这能回答你的问题吗?如果是这样,请将答案标记为这样。干杯。
    • 我已经标记了。我在度数中使用 theta,我将其更改为弧度,现在它正在工作:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-07-21
    • 1970-01-01
    • 2015-04-29
    • 1970-01-01
    • 2015-06-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多