iwiwi 備忘録

学んだことを殴り書きます。自分向けのメモです。

大規模データを gnuplot で描画するために間引く

純粋に間引いて表示

every X という風に書けば X 行ごとに表示してくれる

#!/bin/sh
gnuplot -persistent <<EOF
plot "$1" every 100 u 1:2 with lines lc rgb "blue" title "$1"
EOF

一定区間の平均をとって表示

http://www.ss.scphys.kyoto-u.ac.jp/person/yonezawa/contents/program/gnuplot/average.html

以下のようにすると,x の値が 0.1 ごとにまとめられて平均をとってくれる

#!/bin/sh
gnuplot -persistent <<EOF
filter(x,y)=int(x/y)*y
plot "$1" u (filter(\$1,0.1)):2 with lines lc rgb "blue" smooth unique title "$1"
EOF

おまけ

png で出力するなら以下

set terminal png large size 1024,768
set output "$1.png"