Gnuplot

提供: Wikinote
移動: 案内検索

久々にグラフを描きたくなったのでメモ。

参考文献

使い方

plot コマンド

以下のようなデータで折れ線グラフを書く場合。

"data.txt"
1 10 20 30
2 11 19 31
3 12 20 29
gnuplot> plot [0:5] [0:50] 'data.txt' using 1:2 with line title 'data 1',\
> 'data.txt' using 1:3 with line title 'data 2',\
> 'data.txt' using 1:4 with line title 'data 3'

ファイル書き出し

PNG ファイルに出力する場合。

set terminal png
set output 'image.png'
plot ...

グラフのタイトルや軸名

set title 'Title'
set xlabel 'x axis'
set ylabel 'y axis'

日時を扱う場合

x 軸のデータが HH:MM の場合:

set xdata time
set timefmt '%H:%M'
set xrange ['00:00':'24:00']
set format x '%H' // 軸ラベルの設定