我正在尝试转移正在制作的风向图的基线。因此,径向轴上的零不在中心,而是在基线上。
我知道bottom
的论点,但是当我使用它时,径向刻度在中心处为零。
我的代码(data2d数组是1年的每小时风向数组):
dir_ticks = np.arange(0,360,22.5)
a = data2d[:,4:6].astype(np.float)
winds_dir = data2d[:,5].astype(np.float)
N_i = []
from0to3_i = []
from0to5_i = []
from0to7_i = []
from0to9_i = []
All_probs = len(winds_dir)
for dir_i in dir_ticks:
N_i += [len(np.where(a[:,1]==dir_i)[0])]
N = np.where(a[:,1]==dir_i)
from0to3_i += [len(np.where(np.logical_and(a[N,0]>=0, a[N,0]<3))[0])]
from0to5_i += [len(np.where(a[N,0]<5)[0])]
from0to7_i += [len(np.where(a[N,0]<7)[0])]
from0to9_i += [len(np.where(a[N,0]<9)[0])]
fig = plt.figure(figsize=(5, 5.5), dpi=80, facecolor='w', edgecolor='w')
ax=plt.subplot(111,projection='polar')
ax.set_theta_direction(-1)
ax.set_theta_offset(np.pi/2)
N=16
N_i = np.asarray(N_i)
from0to9_i = np.asarray(from0to9_i)
from0to7_i = np.asarray(from0to7_i)
from0to5_i = np.asarray(from0to5_i)
from0to3_i = np.asarray(from0to3_i)
bottom =5
width = 2*np.pi/(N)-np.pi/(3*N)
b0 = plt.bar(dir_ticks/180*np.pi,N_i/All_probs*100 ,width=width, bottom = bottom, color='#c60000',edgecolor='white')
b1 = plt.bar(dir_ticks/180*np.pi,from0to9_i/All_probs*100,width=width,bottom = bottom, color='y',edgecolor='white')
b2 = plt.bar(dir_ticks/180*np.pi,from0to7_i/All_probs*100,width=width,bottom = bottom,color='g',edgecolor='white')
b3 = plt.bar(dir_ticks/180*np.pi,from0to5_i/All_probs*100,width=width,bottom = bottom, color='c',edgecolor='white')
b4 = plt.bar(dir_ticks/180*np.pi,from0to3_i/All_probs*100,width=width,bottom = bottom, color='b',edgecolor='white')
ax.legend((b4[0],b3[0],b2[0],b1[0],b0[0]),('<3 m/s','3-5 m/s','5-7 m/s','7-9 m/s','>9 m/s'),loc=(0.84,0.91))
plt.yticks(np.arange(3,np.amax(N_i/All_probs*100),3),["%.1f%%" % x for x in np.arange(3,np.amax(N_i/All_probs*100),3)])
ax.set_xticks(theta)
ax.set_xticklabels(['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW'])
plt.tight_layout()
plt.savefig(datafolder + "windrose.png")