繁体   English   中英

Matplotlib极地轮廓线图:在theta原点连续

[英]Matplotlib polar contourf plot: continuous across theta origin

我有E格式的数据( freqtheta ),其中E是2D数组, freqtheta是1D数组。

以下代码部分产生了附图。 但是,我想使轮廓图在0度原点连续(即,沿着0方位没有空白楔形)。

我浏览了matplotlib文档,并广泛地发布了问题,似乎找不到解决此问题的方法。 有任何想法吗?

码:

[r, th] = np.meshgrid(freq,theta)

fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
ax.set_theta_zero_location('N')
ax.set_theta_direction(-1)

cntf = ax.contourf(th,r,np.log10(E),cmap='jet',extend='both',
    levels=np.linspace(np.mean(np.log10(E)), np.amax(np.log10(E)), 15))

ax.set_rlim(0, .3)
label_position=ax.get_rlabel_position()
ax.text(np.radians(label_position+25),ax.get_rmax()/1.5,'f (Hz)',
        rotation=label_position,ha='center',va='center')

产生的情节: 定向波谱

类似于以下内容: https : //stackoverflow.com/a/22129714/9324652

在此处输入图片说明

dtheta = np.diff(theta).mean()
wrp_theta = np.concatenate((theta, theta[-1:] + dtheta))
wrp_E = np.concatenate((E, E[0:1, :]), axis=0)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM