我试图在一个循环中将文本文件中的多个点绘制到同一张图表上。但是,目前,我的代码将每个点绘制为单独的图表。
modname = ['model_a','model_b','model_c','model_d','model_e','model_f']
d = pd.read_table(“ sample.txt”)
for mdl in modname:
pod=d[ (d.MODEL == mdl) & (d.SCORE == "PODY")].VALUE
far=d[ (d.MODEL == mdl) & (d.SCORE == "FAR")].VALUE
csi=d[ (d.MODEL == mdl) & (d.SCORE == "CSI")].VALUE
bias=d[ (d.MODEL == mdl) & (d.SCORE == "FBIAS")].VALUE
sro = 1 - far
print mdl
print pod
print far
print csi
print bias
print sro
fig = plt.figure(figsize=(12,12))
for mdl in modname:
plt.scatter(sro,pod,color=leg_col[i],marker='.',s=750)
plt.savefig(imgdir+outf)
在此示例中,我在第二个循环中缩短了方面。我期望一张图表上有6点,但是我得到6张图表上有1点。我不确定是否设置了错误的循环,或者我将数据保存错误。数据来自文本文件,其标题由空格分隔。
答案 0 :(得分:0)
更改
for mdl in modname:
plt.scatter(sro,pod,color=leg_col[i],marker='.',s=750)
plt.savefig(imgdir+outf)
到
for mdl in modname:
plt.scatter(sro,pod,color=leg_col[i],marker='.',s=750)
plt.savefig(imgdir+outf)
您正在保存每个循环