Gnuplot使用メモ 2007年5月6日(日) 2016年10月17日 (0)csvファイルの散布図描画 d1.txt ======= # d1.txt 1,2 3,4 5,6 7,8 ======= gnuplot> plot "d1.txt" (1)pgnuplot.exeで起動するも、文字がめちゃくちゃ 画面上で右クリック→"choose font"で"terminal" サイズ14あ たりを設定 (2)手始めに、"plot sin(x)" などと打ち込んでみる gnuplot> set xrange [-2*pi:2*pi] gnuplot> a=0.5 gnuplot> plot a*sin(x) (そのうち、なんとなく分かるようになる) (3)3次元表示に挑戦 曲面 z=f(x,y)=sin x cos y の描画をする。 範囲 は - pi ≦ x ≦ pi および - pi/2 ≦ y ≦ pi/2 です。 (http://auemath.aichi-edu.ac.jp/~khotta/ghost/gnuplot.html) gnuplot> splot [-pi:pi] [-pi/2:pi/2] sin(x)*cos(y) 隠線処理 gnuplot> set hidden3d 面を表示する線の数 ( 標準値は 10 本 )を 50 本にする gnuplot> set isosamples 50 視点を固定 set view 60,30 Z軸のゼロ点をXY平面に合わせる set ticslevel 0 set hidden3d set ticslevel 0 set isosamples 50 t=0 a = 10 + 15 * cos(2*pi*t/30) b = 20 +15 * sin(2*pi*t/30) c = 2 + 3 * sin(2*pi*t/30) splot [0:100] [0:100][-1:5] c * exp(-0.01*((x-a)*(x-a)+(y-b)*(y-b))) ========= 3次元ベクトルの表示方法 (1) # Px Py Pz x差分 y差分 z差分 0 0 0 0.8 0.8 0.45 0 0 1 0.5 0.7 0.35 0 0 2 0.7 0.5 0.25 0 1 0 0.65 0.65 0.50 0 1 1 0.6 0.6 0.3 0 1 2 0.45 0.45 0.20 1 0 0 0.5 0.7 0.35 1 0 1 0.75 0.75 0.4 1 0 2 0.85 0.85 0.25 1 1 0 0.90 0.85 0.23 1 1 1 0.95 0.86 0.20 1 1 2 0.98 0.88 0.13 2 0 0 0.73 0.83 0.43 2 0 1 0.53 0.73 0.33 2 0 2 0.73 0.53 0.23 2 1 0 0.68 0.68 0.52 2 1 1 0.63 0.57 0.23 2 1 2 0.48 0.42 0.22 を、"data3d.dat"という名前でセーブ (2) gnuplot> splot "./data3d.dat" with vectors で、3次元ベクトルが表示される ========= データからのポリゴン表示方法 # 以下を"1.dat"でセーブ 0 0 48.400000 0 1 80.400000 0 2 100.000000 0 3 111.600000 0 4 120.000000 0 5 120.000000 1 0 87.600000 1 1 100.000000 1 2 111.200000 1 3 120.000000 1 4 120.000000 1 5 120.000000 2 0 92.000000 2 1 112.400000 2 2 120.000000 2 3 120.000000 2 4 120.000000 2 5 120.000000 3 0 96.000000 3 1 111.600000 3 2 120.000000 3 3 120.000000 3 4 120.000000 3 5 120.000000 4 0 84.400000 4 1 99.600000 4 2 113.600000 4 3 120.000000 4 4 120.000000 4 5 120.000000 5 0 57.600000 5 1 79.200000 5 2 99.600000 5 3 114.400000 5 4 120.000000 5 5 120.000000 splotでは,Z軸の原点は,XY平面から少し離れた所にきます.こ れをXY平面上に持ってきたいときには, set ticslevel を使います.ticslevelの値を0にすると,Z軸の原点がXY平面と一致します. gnuplot> set ticslevel 0 gnuplot>splot [0:5] [0:5] [0:120] "./1.dat" with lines