gnuplot 3次元処理工学 2次元グラフの描画: plot コマンド 数式で表されるグラフの描画 gnuplot> plot sin(x) gnuplot> plot (sin(x)/x)**2 複数の関数を同時にプロットできる: gnuplot> plot sin(x),cos(x) x軸の範囲の指定 gnuplot> plot [-pi:pi] sin(x) y軸の範囲も指定 gnuplot> plot [0:pi] [0:2] sin(x) 関数 使える関数の一覧は functions メニューを参照 加減乗除: + - * / べき乗: ** 自分で新しい関数を定義できる: gnuplot> f(x)=cos(x)+a*sin(x) gnuplot> a=2 gnuplot> plot f(x) gnuplot> a=1 gnuplot> plot f(x) gnuplot> f(a,x)=(sin(a*x)/(a*x))**2 gnuplot> plot f(1,x), f(2,x) 定義済み関数の一覧を表示するには gnuplot> show functions データファイルのプロット まずデータファイルの在るディレクトリに移動 gnuplot> cd '………' gnuplot> plot "test.dat" gnuplot> plot "test.dat" using 1:3 gnuplot> plot "test.dat" with lines gnuplot> plot "test.dat" with points gnuplot> plot "test.dat" with linespoints with points w p と省略できる with lines w p with linespoints w lp データファイルの書式 # yの値だけ 1.0 1.4 1.9 2.2 2.4 # x, 0.0 0.5 0.8 1.5 1.9 y 1.0 1.4 1.9 2.2 2.4 using 1 あるいは using 0:1 using 1:2 # x, 0.0 0.5 0.8 1.5 1.9 y1, 1.0 1.4 1.9 2.2 2.4 y2 2.2 2.1 1.5 1.4 1.1 x軸の値は 0, 1, 2,… 1列目を x、2列目を y に用いる gnuplot> plot "test.dat" using 1:2 w lp, "test.dat" using 1:3 w lp オプションの設定: set コマンド x軸の範囲などを何度も指定するのが面倒な場合、 set コマンドで指定しておくことができる。 gnuplot> set xrange [0:pi] gnuplot> set yrange [0:1] gnuplot> set function style lines gnuplot> set data style linespoints 現在の設定を表示するには show コマンドを用いる: gnuplot> show xrange gnuplot> show data style 最初の状態に戻すには reset コマンドを用いる: gnuplot> reset 3次元プロット: splot gnuplot> splot sin(x)*cos(y) gnuplot> splot [-pi:pi][-pi:pi] sin(x)*cos(y) gnuplot> set hidden3d gnuplot> replot 隠面処理をする gnuplot> set isosamples 50 gnuplot> replot データ点の数を変更 gnuplot> set contour gnuplot> replot 等高線を表示 gnuplot> set cntrparam levels 10 gnuplot> replot gnuplot> set nocontour; replot 等高線の本数 等高線を消去 EPSファイルへの出力 gnuplot> set terminal postscript eps gnuplot> set output 'test.eps' gnuplot> replot これで test.eps というファイルにプロットが 出力される。 通常の画面出力に戻すには以下のようにする: gnuplot> set terminal windows gnuplot> replot TeXへのEPSファイルの取り込み \documentclass{jarticle} \usepackage[dvips]{graphicx} \begin{document} $z=\sin(x)\cos(y)$のグラフです: \begin{center} \includegraphics[width=5cm]{test.eps} \end{center} \end{document}
© Copyright 2025 ExpyDoc