gnuplot / intro / basic
gnuplot 入門 — 基本の基本編 — 起動から終了まで gnuplotは多くのプラットフォーム(OS)に移植されていますので,使い方 まずコマンドラインからgnuplotを起動します.クレジットが表示された % gnuplot G N U P L O T Version 4.0 patchlevel 0 last modified Thu Apr 15 14:44:22 CEST 2004 System: Linux 2.4.23 Copyright (C) 1986 - 1993, 1998, 2004 Thomas Williams, Colin Kelley and many others This is gnuplot version 4.0. Please refer to the documentation for command syntax changes. The old syntax will be accepted throughout the 4.0 series, but all save files use the new syntax. Type `help` to access the on-line reference manual. The gnuplot FAQ is available from http://www.gnuplot.info/faq/ Send comments and requests for help to <[email protected]> Send bugs, suggestions and mods to <[email protected]> Terminal type set to 'x11' gnuplot> "gnuplot> " のプロンプトで使えるコマンドには,大きく分けて
等があります.本当は非常に多くのコマンドが使えるのですが,全てを網羅的 終了,ファイル読み込み,保存のためのコマンド gnuplotは exit か quit コマンドで終了します. gnuplot> save "savefile.plt" 保存したファイルは通常のテキストファイ gnuplotの中で gnuplot> load "savefile.plt" shellのコマンドラインから % gnuplot savefile.plt loadでファイルを読み込む方法と起動時のオプションでの読み込みでは, プロット実行の為のコマンドプロットを実行するコマンドは2つです.2次元プロットでは plot gnuplot> plot sin(x) ![]() これがgnuplotが表示する2次元グラフです.枠の線は太い実線で描かれま 表示範囲を指定しないとき,gnuplotは適当にXやYの範囲をスケーリング gnuplot> plot [0:5] sin(x) ![]() プロットでのパラメータを変更するためのコマンド プロットに関するパラメータは非常にたくさんあり,これらは gnuplot> help set The `set` command can be used to sets _lots_ of options. No screen is drawn, however, until a `plot`, `splot`, or `replot` command is given. The `show` command shows their settings; `show all` shows all the settings. If a variable contains time/date data, `show` will display it according to the format currently defined by `set timefmt`, even if that was not in effect when the variable was initially defined. Subtopics available for set: angles arrow autoscale bar bmargin border boxwidth clabel clip cntrparam contour data dgrid3d dummy encoding format ..... zero zeroaxis zlabel zmtics zrange ztics 幾つかの変数を変えてみましょう.まず,xlabelとylabelに文字列を与え gnuplot> set xlabel "X-AXIS" gnuplot> set ylabel "Y-AXIS" gnuplot> set xrange [0:5] gnuplot> set yrange [-2:2] gnuplot> plot sin(x) ![]() 標準では,gnuplotは画面にグラフを表示します.この出力先を変えて, gnuplot> set terminal Available terminal types: unknown Unknown terminal type - not a plotting device table Dump ASCII table of X Y [Z] values to output linux Linux PC with (s)vgalib .... tpic TPIC -- LaTeX picture environment with tpic specials pstricks LaTeX picture environment with PSTricks macros texdraw LaTeX texdraw environment mf Metafont plotting standard gnuplot> set terminal postscript Terminal type set to 'postscript' Options are 'landscape noenhanced monochrome dashed defaultplex "Helvetica" 14' 上の例のように, set terminal postscript とすると,gnuplot gnuplot> set output "plot.ps" gnuplot> plot sin(x) shellに関するコマンド gnuplotから一時的にshellに抜けることができます.これには pwd と cd は gnuplotのコマンドラインからでも実行できます.pwdはカ 関数の定義,変数への代入,変数内容の表示,計算のためのコマンド gnuplotではコマンドラインで簡単な計算をする事が出来ます.コマンド gnuplot> a=10 gnuplot> print a 10 “変数=計算式” とすると,右辺の計算結果が変数に代入されます.計算は, gnuplot> a=1+2*sqrt(3) gnuplot> print log(a) 1.49606798806764 定義された変数はplotコマンドで関数をプロットするときに使えます.gnuplotで gnuplot> set xrange [-2*pi:2*pi] gnuplot> a=0.5 gnuplot> plot a*sin(x) ![]() ユーザは,自分で関数を定義することができます.例えば,sin(x)*cos(x)という gnuplot> f(x)=sin(x)*cos(x) のように定義します.以後,このf(x)という関数を使うことができます.関数の中に gnuplot> f(x)=a*sin(x)*cos(x) と書くことができます.この関数はaの値によって変化します. |