[英]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.