私はいくつかのデータを持っています。
#Time Distance
1 3
2 5
4 9
8 11
12 17
14 20
16 34
20 40
gnuplot で時間に対する累積距離をプロットしたいのですが (簡単なはずです)、方法がわかりません。
バツ
この種のことをまだ探している人は、gnuplot のバージョンが 4.4 以降であれば、次のことができます。
a=0
#gnuplot 4.4+ functions are now defined as:
#func(variable1,variable2...)=(statement1,statement2,...,return value)
cumulative_sum(x)=(a=a+x,a)
plot "test.dat" using 1:(cumulative_sum($2))
データがファイル datafile にある場合、次のように累積プロットを実行できます。
$ gnuplot
gnuplot> plot "datafile" smooth cumulative
データがファイル「test.txt」にあると仮定すると、次のようになります。
plot "<awk '{i=i+$2; print $1,i}' test.txt" with lines
「smooth」オプションの「cumulative」バリアントでも同じことが実現できます ( help smooth
gnuplot に入力するだけです)。