[英]Matplotlib polar contourf plot: continuous across theta origin
我有E
格式的数据( freq
, theta
),其中E
是2D数组, freq
和theta
是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.