gnuplot / datafile (3)
not so FAQ
|
データファイルの数値のプロット (その3)UNIXのコマンドを利用する. gnuplotはデータファイルの中身を加工しな ここで取り上げているのは,以下のコマンドです. sort sortコマンドを使って,複数のファイルを連結して混ぜ合わせる
% sort -n file1.dat file2.dat 1.0 0.1 2.0 0.2 4.0 0.6 5.0 0.5 5.0 1.0 8.0 0.8 10.0 1.2 12.0 1.3 2つのデータファイルを,それぞれ別のシンボルで表示した後,それら全部 gnuplot> plot "< cat -n file1.dat file2.dat" using 1:2 w l, > "file1.dat" u 1:2 w p, > "file2.dat" u 1:2 w p ![]() pastepaste コマンドは2つ以上のファイルを横に並べて書き出します.
% paste file1.dat file2.dat 1.0 0.1 1.0 0.6 2.0 0.2 2.0 1.0 3.0 0.5 3.0 1.2 4.0 0.8 4.0 1.3 file1.datのX座標とfile2.datのY座標を,(X,Y)として表示するには,次の gnuplot> plot "< paste file1.dat file2.dat" using 2:4 w lp このコマンドを使って,2つのファイルに入っているデータの差や比を表示し gnuplot> plot "< paste file1.dat file2.dat" using 1:($2/$4) w points from Ken. Thanks !
sed ストリームエディタsedを使と,大概のテキスト処理ができます. X座標の1.0を1.2にずらす. gnuplot> plot '<sed "s/^ 1.0/ 1.2/g" file1.dat' 全部の点を表示するが,(2.0,0.2)の点だけ通らない線を描く. gnuplot> plot 'file1.dat' u 1:2 with points, > '<sed "/^ 2.0/d" file1.dat' u 1:2 with lines ![]() 3行目のデータだけを削除する. gnuplot> plot '<sed "3d" file1.dat' u 1:2 with points awk awk も非常に協力な言語で,データファイルの各カラムに対して Yデータの累積値を棒グラフで表示する.Yの値を順次加えていきます.最後 gnuplot> plot "<awk '{x=x+$2; print $1,x}' file1.dat" with boxes ![]() Y座標が0.2より小さいときは,ゼロにする. gnuplot> plot "<awk '{print $1,($2<0.1) ? 0.0 : $2}' file1.dat" with lines Xデータが[1:3]の間だけ,Y値を5倍する. gnuplot> plot "<awk '{print $1,($1<=3 && $1>=1) ? $2*5 : $2}' file1.dat" with lines |