我尝试将7
曲线的标签放在图例中,但是在显示图时,第7条曲线的标签在图上,而其他6条曲线没有标签。
我尝试在不同的缩进中使用plt.legend()
,但是在第3个for循环中,我们有7个以上的标签,因为z
的for循环像其他{for循环中的1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3...
一样,图例无法出现。
我们应该有1 2 3 4 5 6 7
。
有什么帮助吗?
for x in range(len(ng)):
fig,(ax1) = plt.subplots(1,figsize=(9,6))
plt.subplots_adjust(wspace=0.5,hspace=0.1)
for xx in range(1,819):
Ju_list=[]
ET_list=[]
ET1_list=[]
Unu_list=[]
z_list=[]
uf_list=[]
for z in np.arange(0,11):
Ju = dfimppara.iloc[xx,1]
Jl = dfimppara.iloc[xx,2]
lim = Ju - Jl
if lim > 1:
pass
else:
if Ju<8:
Ju_list.append(dfimppara.iloc[xx,1])
T = ET(xx,z,ng[x],1e-24,Tg[x],1)
BC = bcmb(xx,z)
Btex = B(xx,T)
ET_list.append(1-BC/Btex)
z_list.append(z)
l1,=ax1.plot(z_list,ET_list)
ax1.title.set_text(f'UF=1e-24,Tg={Tg[x]},ng={ng[x]}')
ax1.set_ylabel('1-BB(CMB)/BB(Tex)')
ax1.set_xlabel('z')
plt.legend([l1],[f'{dfimppara.iloc[xx,1]}'])
else:
pass
plt.show()