トップ «前の日記(2014年11月26日) 最新 次の日記(2015年01月17日)» 編集

Masa's blog

検索キーワード:

2015年01月11日 gnuplot [長年日記]

_ gnuplot

  • x軸の値を0〜2πに設定
  • サンプリング数を10に設定
  • グリッドの表示を設定
  • sin(x)を描く
  • cos(x)を追加して描く
  • x軸の値を0〜4πに再設定
  • 全体を再描画
set xr[0:2*pi]
set sample 10
set grid
plot sin(x)
replot cos(x)
set xr[0:4*pi]
replot
  • 描画されたものを消去
  • 設定を初期化
  • 図を正方形に設定
  • 媒介変数を使う設定
  • 媒介変数tを0〜2πまで変化させて、円(cos(t), sin(t))を描画
clear
reset
set size square
set parametric
plot [0:2*pi] cos(t),sin(t)
  • y軸をx軸の2倍に引き延ばす設定
  • 再描画
set size ratio 2.0
replot
  • 定数aを2に設定
  • 定数bを10に設定
  • 変数を表示して
  • ax+bを描画
a=2
b=10
show variables
plot a*x+b
  • 関数ax^2+bx+cを定義する
  • 定数aを1に設定
  • 定数bを-5に設定
  • 定数cを6に設定
  • x軸の値を0〜5に設定
  • 定義した関数を描画
f(a,b,c,x)=a*x**2+b*x+c
a=1
b=-5
c=6
set xr[0:5]
plot f(a,b,c,x)
  • 数値の高低(z軸)を色分けする
  • x*x+y*yを描画(3次元)する
set pm3d
splot x*x+y*y
  • 数値の高低を2次元平面に色分けする
  • メッシュのライン数をx軸、y軸共に100に設定する
  • x*x+y*yを描画する
set pm3d map
set isosamples 100,100
splot x*x+y*y
  • 数値の高低を2次元平面に色分けしつつ、3次元に描画する
  • x*x+y*yを描画(3次元)する
set pm3d at b
splot x*x+y*y
  • 2次元平面に高等線を描く設定
  • 真上から見る設定
  • メッシュを消す設定
  • 高等線を10本に設定
  • x*x+y*yを描画(3次元)する
  • 高等線を0から10きざみで100まで描く設定
  • 再描画
set contour
view 0,0
unset surface
set cntrparam levels 10
splot x*x+y*y
set cntrparam levels incremental 0,10,100
replot
  • ファイル(test1.dat)のデータ(x値[space|tab]y値)をプロット
plot "test.dat"
  • ファイル(test2.dat)のデータ(x値[space|tab]y1値[space|tab]y2値)から、x値,y1値を大きさ5のドットとラインで描画
  • ファイル(test2.dat)から、x値,y2値を太さ10のラインで描画
plot "test.dat" using 1:2 w lp ps 5
replot "test.dat" using 1:3 w l lw 10
  • x軸の値を-2〜2に設定
  • y軸の値を-2〜2に設定
  • ファイル(test3.dat)のデータ(x値[space|tab]y値[space|tab]dx値[space|tab]dy値)からベクトルを描画
set xr[-2:2]
set yr[-2:2]
plot "test3.dat" with vector
  • sin(x)を棒グラフで描く
plot sin(x) w boxes
  • x軸のメモリを1きざみに設定する
  • 1メモリを10に細かくきざむ設定にする
  • sin(x)を描く
set xtics 1
set mxtics 10
plot sin(x)
  • y軸を対数表示に設定する
  • exp(x)を描画する
set logscale y
plot exp(x)
  • x軸の名称を"x-line"とする
  • y軸の名称を"y-line"とする
  • sin(x)を描画する
set xl "x-line"
set yl "y-line"
plot sin(x)
  • タイトルを"sin curve"と付けてsin(x)を描画する
  • タイトルを付けずにcos(x)を描画する
plot sin(x) title "sin curve"
replot cos(x) notitle
  • タイトルを左上に設定する
  • sin(x)を描画する
  • タイトルを右下に設定する
  • cos(x)を描画する
set key top left
plot sin(x)
set key bottom right
replot cos(x)
  • 図のタイトルを"sample"と設定する
  • sin(x)を描画する
set title "sample"
plot sin(x)
  • 出力形式をpng画像に設定する
  • 出力ファイルを"sample.png"に設定する
  • sin(x)をファイルに描画する
  • 出力先を元(x11)に戻す
set terminal png
set out "sample.png"
plot sin(x)
set terminal x11
  • x項目名称を-90度回転するように設定
  • ファイル(test4.dat)のデータ(x項目名称[space|tab]y値)棒グラフを描画
set xtics rotate by -90
plot "test4.dat" using 0:2:xtics(1) w boxes
  • 円グラフの為のデータを用意する
$ cat test5.dat
orange  0       120
lemon   120     200
melon   200     260
apple   260     320
other   320     360
  • 図を正方形に設定
  • x軸の値を-1〜1に再設定
  • y軸の値を-1〜1に再設定
  • 凡例を非表示に設定
  • 境界線を非表示に設定
  • x軸目盛を非表示に設定
  • y軸目盛を非表示に設定
  • 角度の単位を(度)に設定
  • 塗りつぶしを透過度(0.4)、枠を黒色に設定
  • ファイル(test5.dat)のデータ(項目名称[space|tab]開始角度[space|tab]終了角度)から、中心座標(0,0)、半径(1)、塗りつぶしの色を(項番+1)で円グラフを描画
  • 続けて、半径(0.7)の位置に項目名称を表示
set size square
set xrange [-1:1]
set yrange [-1:1]
unset key
unset border
unset xtics
unset ytics
set angles degrees
set style fill transparent solid 0.4 border lc rgb "black"
plot "test5.dat" using (0):(0):(1):2:3:($0+1) with circles lc var,\
     "" using (0.7*cos(($2+$3)/2.0)):(0.7*sin(($2+$3)/2.0)):1 with labels