/* $OpenXM: OpenXM/src/asir-contrib/packages/doc/gnuplot.oxweave,v 1.2 2003/07/27 13:18:46 takayama Exp $ */ /*&C-texi @c DO NOT EDIT THIS FILE oxgnuplot.texi */ /*&jp-texi @node GNUPLOT Functions,,, Top @chapter GNUPLOT 函数 この節では GNUPLOT の ox サーバ @code{ox_sm1_gnuplot} とのインタフェース関数を解説する. これらの関数はファイル @file{gnuplot} で定義されている. @code{gnuplot} は @file{$(OpenXM_HOME)/lib/asir-contrib/} にある. */ /*&eg-texi @node GNUPLOT Functions,,, Top @chapter GNUPLOT Functions This chapter describes interface functions for GNUPLOT ox server @code{ox_sm1_gnuplot}. These interface functions are defined in the file @code{gnuplot}. The file @file{gnuplot} is at @* @file{$(OpenXM_HOME)/lib/asir-contrib}. */ /*&C-texi @menu * gnuplot.start:: * gnuplot:: * gnuplot.plot_dots:: * gnuplot.heat:: * gnuplot.plot_function:: * gnuplot.output:: @end menu */ /*&C-texi @example @include opening.texi [255] gnuplot.start(); 0 [257] gnuplot.gnuplot("plot sin(x**2);"); 0 @end example */ /*&eg-texi The function @code{gnuplot.heat}(@var{dt},@var{step}) demonstrates our gnuplot interface. It numerically solves the heat equation @tex $$ {{\partial u}\over{\partial t}} = {{\partial^2 u}\over{\partial x^2}}, \quad u(t,0) = u(t,1) =1 $$ with the initial condition $$ u(0,x) = x, \ (0 \leq x \leq 0.5), \quad u(1,x) = 1-x, \ (0.5 \leq x \leq 1) $$ by the explicit scheme for $0 \leq t \leq \hbox{\it dt}*\hbox{\it step}$. @end tex The segment [0,1] is devided into @code{Heat_N} segments. The static variable @code{Heat_N} can be set by the function @code{gnuplot.heat_set_N}. If the celebrated Courant-Friedrichs-Levi number @var{dt}*@code{Heat_N}*@code{Heat_N} is less than or equal to 0.5, then the explicit scheme is numerically stable. One can observe the instability by changing CFL number. @example gnuplot.heat_set_N(20); gnuplot.heat(0.001,30); (CFL number is 0.4) gnuplot.heat_set_N(20); gnuplot.heat(0.003,30); (CFL > 0.5 unstable) @end example */ /*&jp-texi 関数 @code{gnuplot.heat}(@var{dt},@var{step}) はわれわれの GNUPLOT インタフェース関数のデモ である. この関数は熱伝導方程式 @tex $$ {{\partial u}\over{\partial t}} = {{\partial^2 u}\over{\partial x^2}}, \quad u(t,0) = u(t,1) =1 $$ を初期条件 $$ u(0,x) = x, \ (0 \leq x \leq 0.5), \quad u(1,x) = 1-x, \ (0.5 \leq x \leq 1) $$ で陽的差分法を用いて 時間が $0 \leq t \leq \hbox{\it dt}*\hbox{\it step}$ の範囲で解く. @end tex 区間 [0,1] は @code{Heat_N} 個に分割される. static 変数 @code{Heat_N} は 関数 @code{gnuplot.set_heat_N} で設定する. 有名な Courant-Friedrichs-Levi 数 @var{dt}*@code{Heat_N}*@code{Heat_N} が 0.5 以下であれば, 陽的差分スキームは安定である. CFL を変えることにより, 不安定性が生じるのを観察できる. @example gnuplot.set_heat_N(20); gnuplot.heat(0.001,30); (CFL number is 0.4) gnuplot.set_heat_N(20); gnuplot.heat(0.003,30); (CFL > 0.5 unstable) @end example */ /*&C-texi Author of @code{GNUPLOT}: Thomas Williams, Colin Kelley */ /*&jp-texi @section 函数一覧 */ /*&eg-texi @section Functions */ /*&jp-texi @node gnuplot.start,,, GNUPLOT Functions @subsection @code{gnuplot.start} @findex gnuplot.start @table @t @item gnuplot.start() :: Localhost で @code{ox_sm1_gnuplot} を起動する. @end table @table @var @item return 整数 @end table @itemize @bullet @item Localhost で @code{ox_sm1_gnuplot} を起動する. 起動された @code{ox_sm1_gnuplot} の識別番号を戻す. @item @code{Xm_noX =1} としておくと, @code{ox_sm1_gnuplot} 用の debug window が開かない. @item 識別番号は, @code{Gnuplot_proc} に格納される. @end itemize */ /*&eg-texi @node gnuplot.start,,, GNUPLOT Functions @subsection @code{gnuplot.start} @findex gnuplot.start @table @t @item gnuplot.start() :: Start @code{ox_sm1_gnuplot} on the localhost. @end table @table @var @item return Integer @end table @itemize @bullet @item Start @code{ox_sm1_gnuplot} on the localhost. It returns the descriptor of @code{ox_sm1_gnuplot}. @item Set @code{Xm_noX = 1} to start @code{ox_sm1_gnuplot} without a debug window. @item The descriptor is stored in @code{Gnuplot_proc}. @end itemize */ /*&C-texi @example P = gnuplot.start(); @end example */ /*&jp-texi @table @t @item 参照 @code{ox_launch}, @code{gnuplot} @end table */ /*&eg-texi @table @t @item Reference @code{ox_launch}, @code{gnuplot} @end table */ /*&eg-texi @node gnuplot,,, GNUPLOT Functions @subsection @code{gnuplot} @findex gnuplot @table @t @item gnuplot.gnuplot(@var{s}|proc=@var{p}) :: Ask GNUPLOT to execute the command string @var{s}. @end table @table @var @item return Void @item p Number @item s String @end table @itemize @bullet @item The server executes the gnuplot command @var{s}. When an error occurs, the gnuplot itself terminates and ox_sm1_gnuplot server automatically restarts gnuplot. @item gnuplot does not accept a long polynomial. @item gnuplot does not accept @code{^}. Use @code{**} instead. @end itemize */ /*&jp-texi @node gnuplot,,, GNUPLOT Functions @subsection @code{gnuplot} @findex gnuplot @table @t @item gnuplot.gnuplot(@var{s}|proc=@var{p}) :: GNUPLOT にコマンド @var{s} を実行してもらう. @end table @table @var @item return なし @item p 数 @item s 文字列 @end table @itemize @bullet @item サーバは GNUPLOT のコマンド @var{s} を実行する. エラーがおきた場合 GNUPLOT 本体は終了してしまうが, @code{ox_sm1_gnuplot} は自動的に GNUPLOT 本体をリスタートする. @item GNUPLOT は長い多項式をただしくうけつけない. @item GNUPLOT は @code{^} をうけつけない. かわりに, @code{**} を使う. @end itemize */ /*&C-texi @example [232] P = gnuplot.start(); 0 *Plot 3 dimensional graph. [233] gnuplot.gnuplot("splot x**2-y**2;"|proc=P); 0 *Plot 2 dimensional graph. [234] gnuplot.gnuplot("plot [-pi:pi] [-2:2] cos(x);"); 0 *Output a graph as a postscript figure. [235] gnuplot.output(|file="hoge.eps"); 0 [236] gnuplot.gnuplot("plot sin(x)*cos(x);"); 0 [237] gnuplot.gnuplot(|file="x11"); 0 *Plot 3 dimensional graph hiding unvisible lines. [236] gnuplot.gnuplot("set hidden3d"); 0 [237] gnuplot.gnuplot("splot (x**2+y**2)*sin(x**2+y**2)"); 0 [238] gnuplot.gnuplot("set isosamples 50"); 0 [239] gnuplot.gnuplot("splot (x**2+y**2)*sin(x**2+y**2)"); @end example */ /*&eg-texi @table @t @item Reference @code{ox_launch}, @code{gnuplot.start}, @code{rtostr}, @code{gnuplot.plot_dots} @item Reference Book Yabuki Michiro, Otake Tuyoshi; Tukai konasu GNUPLOT, Techno Press, in Japansese, ISBN4-924998-11-7 @end table */ /*&jp-texi @table @t @item 参照 @code{ox_launch}, @code{gnuplot.start}, @code{rtostr}, @code{gnuplot.plot_dots} @item 参考書 矢吹道郎, 大竹つよし; 使いこなす GNUPLOT, テクノプレス, ISBN4-924998-11-7 @end table */ /*&eg-texi @node gnuplot.plot_dots,,, GNUPLOT Functions @subsection @code{gnuplot.plot_dots} @findex gnuplot.plot_dots @table @t @item gnuplot.plot_dots(@var{d},@var{s}|proc=@var{p}) :: Plot the dots @var{d} with the style @var{s}. @end table @table @var @item return Void @item p Number @item d List @item s String or 0 @end table @itemize @bullet @item Plot the dots @var{d} with the style @var{s}. @var{s} is a string of the form "style color point". Here, style can be lines, points, linespoints, impulses, dots, steps, errorbars, boxes, boxerrorbars. color can be 1 (red), 2 (green), 3 (blue), 4, ... , 8. point can be a number from 1 to 8. The color and point field can be omitted. @item When @var{d} == @code{[ ]}, the screen will be cleared. @end itemize */ /*&jp-texi @node gnuplot.plot_dots,,, GNUPLOT Functions @subsection @code{gnuplot.plot_dots} @findex gnuplot.plot_dots @table @t @item gnuplot.plot_dots(@var{d},@var{s}|proc=@var{p}) :: 点の集合 @var{d} をスタイル @var{s} でプロットする. @end table @table @var @item return なし @item p 数 @item d リスト @item s 文字列 または 0 @end table @itemize @bullet @item 点集合 @var{d} をスタイル @var{s} でプロットする. @var{s} は次のような文字列: "style color point". ここで style には lines, points, linespoints, impulses, dots, steps, errorbars, boxes, boxerrorbars を選べる. color には 1 (red), 2 (green), 3 (blue), 4, ... , 8 を選べる. point は 1 から 8 の数を入れる. color, point は省略してよい. @item @var{d} == @code{[ ]} のときはスクリーンがまず消去される. @end itemize */ /*&C-texi @example [239] P = gnuplot.start(); 0 [240] gnuplot.plot_dots([ ],0); 0 [241] for (I=0; I<10; I++) gnuplot.plot_dots([[I,I^2]]," lines "); [242] A = [ ]; [] [243] for (I=0; I<10; I++) A = append(A,[ [I,I^2]]); [244] A; [[0,0],[1,1],[2,4],[3,9],[4,16],[5,25],[6,36],[7,49],[8,64],[9,81]] [245] gnuplot.plot_dots(A," lines "); 0 @end example */ /*&jp-texi @table @t @item 参照 @code{gnuplot.start}, @code{plot "fileName" with options}(GNUPLOT command), @code{gnuplot.clean}, @code{gnuplot} @end table */ /*&eg-texi @table @t @item Reference @code{gnuplot.start}, @code{plot "fileName" with options}(GNUPLOT command), @code{gnuplot.clean}, @code{gnuplot} @end table */ /** heat equation **/ /*&eg-texi @node gnuplot.heat,,, GNUPLOT Functions @subsection @code{gnuplot.heat} @findex gnuplot.heat @table @t @item gnuplot.heat(@var{dt},@var{step}) :: It solves the heat equation numerical and plots solutions @end table @table @var @item return Void @item dt floating point number @item step Integer @end table @itemize @bullet @item It solves the heat equation du/dt = d^2 u/dx^2, u(t,0) = u(t,1) = 0 with the initial condition u(0,x) = x (0 <= x <= 0.5), u(0,x) = 1-x ( 0.5 <= x <= 1.0). @item Heat_N is the number of the meshes in the space. @item This function will be called @code{pde_heat_demo} in a future. @end itemize @noindent Algorithm: NOT Written. (Difference scheme. Courant-Levi-Friedrichs conditions.) */ /*&jp-texi @node gnuplot.heat,,, GNUPLOT Functions @subsection @code{gnuplot.heat} @findex gnuplot.heat @table @t @item gnuplot.heat(@var{dt},@var{step}) :: 熱伝導方程式を数値的に解く. @end table @table @var @item return なし @item dt 浮動小数点数 @item step 整数 @end table @itemize @bullet @item 熱伝導方程式 du/dt = d^2 u/dx^2, u(t,0) = u(t,1) = 0 を初期条件 u(0,x) = x (0 <= x <= 0.5), u(0,x) = 1-x ( 0.5 <= x <= 1.0) で解く. @item Heat_N は空間方向でのメッシュの数. @item この関数は将来 @code{pde_heat_demo} と呼ばれる予定. @end itemize */ /*&C-texi @example [232] Heat_N = 20$ [233] gnuplot.heat(0.001,30)$ @end example */ /*&eg-texi @node gnuplot.output,,, GNUPLOT Functions @subsection @code{gnuplot.output} @findex gnuplot.output @table @t @item gnuplot.output(|@var{file=s}) :: ask @code{GNUPLOT} to output graphic to the file @var{s} in the Postscript format. @end table @table @var @item return Void @item s String @end table @itemize @bullet @item ask @code{GNUPLOT} to output graphic to the file @var{s} in the Postscript format. @item When @code{s} is "x11" or this function is called without the argument, the output will be written to X11 display. @end itemize */ /*&jp-texi @node gnuplot.output,,, GNUPLOT Functions @subsection @code{gnuplot.output} @findex gnuplot.output @table @t @item gnuplot.output(|@var{file=s}) :: @code{GNUPLOT} にファイル @var{s} へポストスクリプトで出力するように頼む. @end table @table @var @item return Void @item s String @end table @itemize @bullet @item @code{GNUPLOT} にファイル @var{s} へポストスクリプトで出力するように頼む. @item @code{s} が "x11" または, この関数を引数無しでよぶと, 以後, X11 の display に graphics が出力される. @end itemize */ /*&C-texi @example [273] gnuplot.output(|file="hoge.eps"); Graphic output of GNUPLOT will be written to hoge.eps as a Poscript file. 0 [274] gnuplot.gnuplot("plot tan(x)+sin(x);"); 0 [275] gnuplot.output(); Usage of gnuplot.output: gnuplot.output(|file="string") gnuplot.output(|file="x11") Output device is set to X11 @end example */ /*&eg-texi @table @t @item Reference @code{gnuplot} @end table */ /*&jp-texi @table @t @item 参照 @code{gnuplot} @end table */ /*&eg-texi @node gnuplot.plot_function,,, GNUPLOT Functions @subsection @code{gnuplot.plot_function} @findex gnuplot.plot_function @table @t @item gnuplot.gnuplot(@var{f}|proc=@var{p}) :: ask the @code{gnuplot} server to draw a graph of @var{f} @end table @table @var @item return Void @item p Number @item f Polynomial or a list of polynomials @end table @itemize @bullet @item ask the @code{gnuplot} server to draw a graph of @var{f} @end itemize */ /*&jp-texi @node gnuplot.plot_function,,, GNUPLOT Functions @subsection @code{gnuplot.plot_function} @findex gnuplot.plot_function @table @t @item gnuplot.plot_function(@var{f}|proc=@var{p}) :: @code{gnuplot} サーバに @var{f} のグラフを書くように頼む. @end table @table @var @item 戻り値 なし @item p 数 @item f 多項式または多項式のリスト @end table @itemize @bullet @item @code{gnuplot} サーバに @var{f} のグラフを書くように頼む. @end itemize */ /*&C-texi @example [290] gnuplot.plot_function((x+sin(x))^2); 0 [291] gnuplot.plot_function([x,x^2,x^3]); 0 @end example */ /*&eg-texi @table @t @item Reference @code{gnuplot.to_gnuplot_format} @end table */ /*&jp-texi @table @t @item 参照 @code{gnuplot.to_gnuplot_format} @end table */ end$