0
我有一個函數,它接受輸入,3個數組和一個常量值。for循環中的Matplotlib子圖
函數內部我給出了10個不同的條件,並試圖在10個不同的子圖中繪製它們。
def ra_vs_dec(alpha,delta,zphot,mlim):
zmin = [0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2]
zmax = [0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3]
plot_no = [1,2,3,4,5,6,7,8,9,10] # THESE ARE THE SUBPLOT NUMBERS
for a,b,c in zip(zmin,zmax,plot_no):
ra = alpha[(data_m200>mlim)*(data_z>a)*(data_z<b)] # RA FOR ZCOSMO
dec = delta[(data_m200>mlim)*(data_z>a)*(data_z<b)] # DEC FOR ZCOSMO
ra_zphot = alpha[(data_m200>mlim)*(zphot>a)*(zphot<b)] # RA FOR ZPHOT
dec_zphot = delta[(data_m200>mlim)*(zphot>a)*(zphot<b)] # DEC FOR ZPHOT
fig = plt.figure()
ax = fig.add_subplot(2,5,c)
ax.scatter(ra,dec,color='red',s=5.0,label=''+str(a)+'<zcosmo<'+str(b)+'')
ax.scatter(ra_zphot,dec_zphot,color='blue',s=5.0,label=''+str(a)+'<zphot<'+str(b)+'')
ax.legend(loc='best',scatterpoints=2)
fig.show()
然而,當我運行上面的代碼,我只得到了最後的插曲,即10日的插曲。我在這裏做錯了什麼?
我希望看到所有的10個子圖。