简体   繁体   English

极坐标中的 pcolormesh - redux

[英]pcolormesh in polar coordinates - redux

So I cannot get a polar surface plot of this doppler map.所以我无法得到这个多普勒 map 的极面 plot。 Here's the setup:这是设置:

phis = np.linspace(0.0001,50,51) 
thetas = np.linspace(0,360,721)

doppMap = \
    np.array([[doppler(i * deg, j * deg).value for i in thetas] for j in phis]) * units.kHz

So I now have a 2D array of doppler values going from 0-360 in theta, and from 0-50 in phi... If I plot this in cartesian coordinates it looks like what I expect:所以我现在有一个二维的多普勒值数组,从 0-360 到 0-360,从 0-50 到 phi ......

在此处输入图像描述

This works with two different calls to pcolomesh :这适用于对pcolomesh的两个不同调用:

fig, ax = plt.subplots(figsize=(8,4))

X, Y = np.meshgrid(thetas, phis)  # Create a grid over the range of bins for the plot
im = (ax.pcolormesh(thetas, phis, doppMap, cmap=mpl.cm.jet_r, alpha=0.95,shading='auto',edgecolors='face') )
## or
im = (ax.pcolormesh(X, Y, doppMap, cmap=mpl.cm.jet_r, alpha=0.95,shading='auto',edgecolors='face') )


ax.set_xlabel("theta [$\degree$]",fontsize=14)
ax.set_ylabel("phi [$\degree$]",fontsize=14)
ax.set_xticks([x*30 for x in range(360//30)])
ax.grid(True)

plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
## Add colorbar
cbar_ax = fig.add_axes([0.95, 0.15, 0.015, 0.7])
cbar = fig.colorbar(im, cax=cbar_ax)
cbar.ax.tick_params(labelsize=14) 
#cbar.ax.set_yticklabels(['1', '2', '4', '6', '10', maxCV], size=24)
#cbar.set_label(r"log ($P(\overline{Z_{G}} /Z_{\odot})$ / $d(M_{G}/M_{\odot})$)",fontsize=36)
cbar.set_label(r"$d$f [kHz]",fontsize=24)

gc.collect()

However, when I try this:但是,当我尝试这个时:

fig, ax = plt.subplots(figsize=(8,7),subplot_kw=dict(projection='polar'))

X, Y = np.meshgrid(thetas,phis)  # Create a grid over the range of bins for the plot

im = (ax.pcolormesh(thetas,phis, doppMap, cmap=mpl.cm.jet_r, alpha=0.95,shading='auto',edgecolors='face') )
## or
im = (ax.pcolormesh(X, Y, doppMap, cmap=mpl.cm.jet_r, alpha=0.95,shading='auto',edgecolors='face') )


ax.set_theta_direction(-1)
ax.set_theta_offset(np.pi / 2.0)

plt.thetagrids([theta * 15 for theta in range(360//15)])
ax.grid(True)

plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
## Add colorbar
cbar_ax = fig.add_axes([0.95, 0.15, 0.015, 0.7])
cbar = fig.colorbar(im, cax=cbar_ax)
cbar.ax.tick_params(labelsize=14) 
#cbar.ax.set_yticklabels(['1', '2', '4', '6', '10', maxCV], size=24)
#cbar.set_label(r"log ($P(\overline{Z_{G}} /Z_{\odot})$ / $d(M_{G}/M_{\odot})$)",fontsize=36)
cbar.set_label(r"$d$f [kHz]",fontsize=24)

gc.collect()

I see this (which is completely wrong):我看到了这个(这是完全错误的): 在此处输入图像描述

Anyone know what I'm doing wrong?有人知道我在做什么错吗?

Thx谢谢

So I figured it out...所以我想通了...

phis2   = np.linspace(0.001,50,201) 
thetas2 = np.linspace(0,2.01*np.pi,201)

print(phis2.shape,thetas2.shape)

X,Y = np.meshgrid(thetas2,phis2)
doppMap2 =doppler(X*units.rad,Y*deg)

fig, ax = plt.subplots(figsize=(8,7),subplot_kw=dict(projection='polar'))

im=ax.pcolormesh(X,Y,doppMap2,cmap=mpl.cm.jet_r, edgecolors='face')
ax.set_theta_direction(-1)
ax.set_theta_offset(np.pi / 2.0)

# ax.set_xticks([x*30 for x in range(360//30)])
ax.grid(True)

plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
## Add colorbar
cbar_ax = fig.add_axes([0.95, 0.15, 0.015, 0.7])
cbar = fig.colorbar(im, cax=cbar_ax)
cbar.ax.tick_params(labelsize=14) 
#cbar.ax.set_yticklabels(['1', '2', '4', '6', '10', maxCV], size=24)
#cbar.set_label(r"log ($P(\overline{Z_{G}} /Z_{\odot})$ / $d(M_{G}/M_{\odot})$)",fontsize=36)
cbar.set_label(r"$d$f [kHz]",fontsize=24)

Results in结果是

在此处输入图像描述

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

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