首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >对一维向量使用matplotlibs contourf函数

对一维向量使用matplotlibs contourf函数
EN

Stack Overflow用户
提问于 2012-11-19 19:38:46
回答 1查看 2.5K关注 0票数 0

我有一个大型数据集,其中包含一个月内每天的三个大型单列向量(后向角、频率和功率)。我想使用像contourf这样的东西在极地图上显示数据。但是,我不确定如何将power数据重塑为2D数组。下面是一个示例。

代码语言:javascript
复制
from pylab import *

x=rand(100)
y=rand(100)
z = rand(100)    # 1D

BAZ, FREQ = meshgrid(x, y)
ax = plt.subplot(111, polar=True)
contourf(BAZ, FREQ, z)       # z needs to be 2D

有没有人知道我如何重塑z,让它工作?谢谢,大卫

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-19 20:45:32

来自tiago上面评论中的链接的答案是,

代码语言:javascript
复制
x=rand(100)
y=rand(100)
z = rand(100) 

xgrid = np.linspace(x.min(), x.max(), 100)
ygrid = np.linspace(y.min(), y.max(), 100)
xgrid, ygrid = np.meshgrid(xgrid, ygrid)
zgrid = griddata((x,y),z, (xgrid, ygrid))

ax = plt.subplot(111, polar=True)
contourf(xgrid, ygrid, zgrid)   

谢谢,

D。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13453000

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档