Gnuplot の使い方 (2次元表示のみ)
目次
起動と終了起動と終了
% gnuplot |
gnuplot> |
gnuplot> exit gnuplot> quit gnuplot> q |
グラフの描画
基本的に、gnuplot> plot function with linestyle [, function with linestyle ] |
gnuplot> plot sin(x) with lines |
gnuplot> plot sin(x) with lines, -2.0*x/3.0+1 with points |
points | 点 (デフォルト) |
---|---|
lines | 線 |
linespoints | 線と点 |
dots | 小さな点 |
boxes | 棒グラフ |
% cat test.dat # Test data 0.31 1.2 -0.66 0.35 2.7 -0.76 0.45 3.7 -0.64 0.42 4.4 -0.52 0.50 5.2 -0.48 0.53 6.3 -0.50 0.63 7.6 -0.06 |
gnuplot> plot "test.dat" using 2:1 with linespoints |
グラフのカスタマイズ
基本的に、gnuplot> set option |
gnuplot> help set |
軸範囲の指定
set xrange [Xmin:Xmax] set yrange [Ymin:Ymax] |
軸名の指定
set xlabel "label name on X" set ylabel "label name on Y" |
グラフ名の指定
set title "name" |
線の名前
plot function title "name" |
軸の目盛
set xtics 最小値, 増分, 最大値 |
set xtics -10, 2, 20 |
もしくは、
set xtics ( 0.0, 7.0, 12.8, 20.0 ) |
set xtics ( "origin" 0.0, "next" 7.0, "{/Symbol p}" 20.0 ) |
set format x "%4.2f" |
set format y "" |
log scale
X軸を対数表示に
set log x |
set nolog x |
グリッドを表示
X軸にグリッドを入れる
set grid x |
set nogrid |
複数のグラフを表示。
multiplot モードに変換する。gnuplot> set multiplot |
multiplot> set size 0.8,0.4 |
multiplot> set origin 0.1,0.1 |
multiplot> plot [-2.0*pi:2.0*pi] [-2:2] 1.5*sin(x) title "first.plot" |
multiplot> set origin 0.1,0.45 |
multiplot> plot [-2.0*pi:2.0*pi] [-2:2] 1.5*cos(x) title "second.plot" |
multiplot> set nomultiplot |
ポストスクリプトファイルへの出力
gnuplot> set terminal postscript style fontsize |
gnuplot> set output "file_name" |
landscape | 横長 |
---|---|
portrait | 縦長 |
eps | EPS 形式 |
例: gnuplot> set terminal postscript landscape 20 gnuplot> set output "test.ps" gnuplot> plot sin(x) |
gnuplot> set terminal eps enhanced 20 |
関数のフィッティング
任意の関数を、データに対してフィッティングさせて 係数を求めることができる。
関数の定義:
gnuplot> f(x) = a*x + b |
gnuplot> fit [-10:20] f(x) "test.dat" using 2:1 via a,b |
gnuplot> plot "test.dat" using 2:1, f(x) |