シミュレーションの結果、Pandas groupby()
を使用して出力を解析しました。私は、私が望むようにデータをプロットするのが少し難しいです。ここで私はプロットにしようとしている(簡略化のために抑制さ)パンダの出力ファイルがあります:Pandas、Matplotlib、Numpyの2D配列をプロット
Avg-del Min-del Max-del Avg-retx Min-retx Max-retx
Prob Producers
0.3 1 8.060291 0.587227 26.709371 42.931779 5.130041 136.216642
5 8.330889 0.371387 54.468836 43.166326 3.340193 275.932170
10 1.012147 0.161975 4.320447 6.336965 2.026241 19.177802
0.5 1 8.039639 0.776463 26.053635 43.160880 5.798276 133.090358
5 4.729875 0.289472 26.717824 25.732373 2.909811 135.289244
10 1.043738 0.160671 4.353993 6.461914 2.015735 19.595393
私のy軸は、遅延と私のx軸は生産者の数です。確率p=0.3
と誤差範囲p=0.5
のエラーバーが必要です。 私のPythonスクリプトは以下の通りです:
import sys
import time
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
pd.set_option('display.expand_frame_repr', False)
outputFile = 'averages.txt'
f_out = open(outputFile, 'w')
data = pd.read_csv(sys.argv[1], delimiter=",")
result = data.groupby(["Prob", "Producers"]).mean()
print "Writing to output file: " + outputFile
result_s = str(result)
f_out.write(result_s)
f_out.close()
*** Update from James ***
for prob_index in result.index.levels[0]:
r = result.loc[prob_index]
labels = [col for col in r]
lines = plt.plot(r)
[line.set_label(str(prob_index)+" "+col) for col, line in zip(labels, lines)]
ax = plt.gca()
ax.legend()
ax.set_xticks(r.index)
ax.set_ylabel('Latency (s)')
ax.set_xlabel('Number of producer nodes')
plt.show()
今、私は4つのスライスのアレイ、各確率のための1つを持っています。 遅延(del)とretx、およびave、min、maxに基づいてプロットエラーバーに基づいて再スライスするにはどうすればよいですか?
こんにちはジェームズ、ご返信用 感謝。 'r'は' results'を取得し、 'Prob'はインデックスを取得しました。良い。 私のデータセットにはより多くの列があるため、1つの質問が残っていますが、どのように 'r'をスライスするのですか? あなたのコードに基づいて質問を更新します。 ありがとう – Thiago