我是Python的新手,来自更Matlab的观点.我试图制作一系列2 x 5面板contourf子图.到目前为止,我的方法是将我的Matlab代码转换(在某种程度上)到Python并在循环中绘制我的子图.代码的相关部分如下所示:
fig=plt.figure(figsize=(15, 6),facecolor='w', edgecolor='k')
for i in range(10):
#this part is just arranging the data for contourf
ind2 = py.find(zz==i+1)
sfr_mass_mat = np.reshape(sfr_mass[ind2],(pixmax_x,pixmax_y))
sfr_mass_sub = sfr_mass[ind2]
zi = griddata(massloclist, sfrloclist, sfr_mass_sub,xi,yi,interp='nn')
temp = 250+i # this is to index the position of the subplot
ax=plt.subplot(temp)
ax.contourf(xi,yi,zi,5,cmap=plt.cm.Oranges)
plt.subplots_adjust(hspace = .5,wspace=.001)
#just annotating where each contour plot is being placed
ax.set_title(str(temp))
Run Code Online (Sandbox Code Playgroud)
作为这个论坛的新手,我似乎不允许附加结果图像.但是,通过我在代码中的索引作为'temp',2 x 5面板的最终布局是:
251 - 252 - 253 - 254 - 255
256 - 257 - 258 - 259 …Run Code Online (Sandbox Code Playgroud)