我发生了一些奇怪的事情。我正在尝试绘制多条线,它显示了图例中的所有图,但是缺少一条线。这个怎么可能? 我正在读取包含我的数据的文件,该文件有效!
这是我的代码:
f = open(wk_dir+"/Total_Evaluation.txt","r+")
with open(wk_dir+"/Total_Evaluation.txt","r+") as f1:
data10 = f1.read()
data11=data10.replace(","," ")
TESTDATA = StringIO(data11)
df_eval = pd.read_table(TESTDATA, sep=" ")
df_eval.columns = ["alternativesFound", "alternativesOne","alternativesPenalty","trajectory_amount","resolution","map_name","runtimeAlgo","runtimePathlet","runtimePrePro","runtimeDijkstra","dijkstraLength","runtimeIntersection","runtimeHomotopy","runtimeRTree"]
#ALTERNATIVES FOUND/TRAJEKTORY INPUT EVALUATION
fig, ax = plt.subplots()
x=[]
y1=[]
y2=[]
y3=[]
y4=[]
y5=[]
for i, g in df_eval.groupby('trajectory_amount'):
foundAlt=df_eval["alternativesFound"].mean()
y1.append(foundAlt)
foundMax=df_eval["alternativesFound"].max()
y2.append(foundMax)
foundMin=df_eval["alternativesFound"].min()
y3.append(foundMin)
foundOne=df_eval["alternativesOne"].mean()
y4.append(foundOne)
foundPen=df_eval["alternativesPenalty"].mean()
y5.append(foundPen)
x.append(i)
df=pd.DataFrame({'x': x, 'y1': y1, 'y2': y2, 'y3': y3, 'y4': y4, 'y5': y5 })
plt.plot( 'x', 'y1',data=df, marker='o',label="Durchschnittlich gefundene Routen")
plt.plot( 'x', 'y2',data=df, marker='o',label="Minimum gefundener Routen")
plt.plot( 'x', 'y3',data=df, marker='o',label="Maximum gefundener Routen")
plt.plot( 'x', 'y4',data=df, marker='o',label="Durchschnittilch gefundene Routen One-Patching")
plt.plot( 'x', 'y5',data=df, marker='o',label="Durchschnittilch gefundene Routen Penalty")
plt.title("Verhaeltnis von gefundenen alternativen Routen und Groesse des Trajektorieninputs")
plt.legend()
plt.savefig("Alterantives_TrajectoryInput_Evaluation.png")
下面是一个仅显示4行而不是5行的图的示例(缺少红色的一行):
有人知道怎么可能吗?我正在以这种方式绘制几个图形,所以在这段代码之后,我只是用不同的变量名来显示相同的行