python - 绘制多条线但并非全部显示在图表中
问题描述
我有一些奇怪的事情发生。我正在尝试绘制几条线,它显示了图例中的所有图,但缺少一条线。这个怎么可能?我正在阅读一个包含我的数据的文件,它有效!
这是我的代码:
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 行的绘图示例(缺少红色的行):
有谁知道那是怎么回事?我以这种方式绘制了几个数字,所以在这段代码之后,我只有相同的行,只是变量名不同
解决方案
推荐阅读
- javascript - HTML 输入到数字和添加
- powershell - 从 Hashicorp Vault 将机密复制到 Azure Key Vault
- http - 更改 web html 内容/在 http 请求上运行 bash 脚本
- c# - 如何在 VS 2019 中将 XNA 与 Windows 窗体匹配?
- c# - EF Core 中的 GetColumnBaseName 和 GetColumnName 有什么区别?
- sql - 我如何在 order by 时使用案例?
- c - 此链接列表的头部在递归语句之后指向的位置
- sql-server - 我想创建触发器来更新基于多个字符串过滤器的列中插入或更新的值
- django - 在 djangofilterbackends 中修改 django 中的 query_params
- php - 当对象存在时尝试获取非对象的属性“totalInterestPaid”