Annotation of OpenXM/src/asir-contrib/packages/doc/gnuplot.oxweave, Revision 1.4
1.4 ! ohara 1: /* $OpenXM: OpenXM/src/asir-contrib/packages/doc/gnuplot.oxweave,v 1.3 2004/03/05 15:30:50 ohara Exp $ */
1.1 takayama 2:
3:
1.4 ! ohara 4: /*&C
1.1 takayama 5: @c DO NOT EDIT THIS FILE oxgnuplot.texi
6: */
1.3 ohara 7: /*&ja
1.2 takayama 8: @node GNUPLOT Functions,,, Top
1.1 takayama 9: @chapter GNUPLOT $BH!?t(B
10:
11: $B$3$N@a$G$O(B GNUPLOT $B$N(B ox $B%5!<%P(B @code{ox_sm1_gnuplot}
12: $B$H$N%$%s%?%U%'!<%94X?t$r2r@b$9$k(B.
13: $B$3$l$i$N4X?t$O%U%!%$%k(B @file{gnuplot} $B$GDj5A$5$l$F$$$k(B.
14: @code{gnuplot} $B$O(B
15: @file{$(OpenXM_HOME)/lib/asir-contrib/} $B$K$"$k(B.
16: */
1.3 ohara 17: /*&en
1.1 takayama 18: @node GNUPLOT Functions,,, Top
19: @chapter GNUPLOT Functions
20:
21: This chapter describes interface functions for
22: GNUPLOT ox server @code{ox_sm1_gnuplot}.
23: These interface functions are defined in the file @code{gnuplot}.
24: The file @file{gnuplot} is at @*
25: @file{$(OpenXM_HOME)/lib/asir-contrib}.
26: */
1.4 ! ohara 27: /*&C
1.2 takayama 28:
29: @menu
30: * gnuplot.start::
31: * gnuplot::
32: * gnuplot.plot_dots::
33: * gnuplot.heat::
34: * gnuplot.plot_function::
35: * gnuplot.output::
36: @end menu
37:
38: */
1.4 ! ohara 39: /*&C
1.1 takayama 40: @example
41: @include opening.texi
42: [255] gnuplot.start();
43: 0
44: [257] gnuplot.gnuplot("plot sin(x**2);");
45: 0
46: @end example
47: */
1.3 ohara 48: /*&en
1.1 takayama 49: The function
50: @code{gnuplot.heat}(@var{dt},@var{step}) demonstrates our gnuplot interface.
51: It numerically solves the heat equation
52: @tex
53: $$ {{\partial u}\over{\partial t}} = {{\partial^2 u}\over{\partial x^2}},
54: \quad u(t,0) = u(t,1) =1
55: $$
56: with the initial condition
57: $$ u(0,x) = x, \ (0 \leq x \leq 0.5), \quad
58: u(1,x) = 1-x, \ (0.5 \leq x \leq 1)
59: $$
60: by the explicit scheme for $0 \leq t \leq \hbox{\it dt}*\hbox{\it step}$.
61: @end tex
62: The segment [0,1] is devided into @code{Heat_N} segments.
63: The static variable @code{Heat_N} can be set by the function
64: @code{gnuplot.heat_set_N}.
65: If the celebrated Courant-Friedrichs-Levi number
66: @var{dt}*@code{Heat_N}*@code{Heat_N} is less than or equal to 0.5,
67: then the explicit scheme is numerically stable.
68: One can observe the instability by changing CFL number.
69: @example
70: gnuplot.heat_set_N(20); gnuplot.heat(0.001,30); (CFL number is 0.4)
71: gnuplot.heat_set_N(20); gnuplot.heat(0.003,30); (CFL > 0.5 unstable)
72: @end example
73: */
1.3 ohara 74: /*&ja
1.1 takayama 75: $B4X?t(B
76: @code{gnuplot.heat}(@var{dt},@var{step}) $B$O$o$l$o$l$N(B GNUPLOT $B%$%s%?%U%'!<%94X?t$N%G%b(B
77: $B$G$"$k(B.
78: $B$3$N4X?t$OG.EAF3J}Dx<0(B
79: @tex
80: $$ {{\partial u}\over{\partial t}} = {{\partial^2 u}\over{\partial x^2}},
81: \quad u(t,0) = u(t,1) =1
82: $$
83: $B$r=i4|>r7o(B
84: $$ u(0,x) = x, \ (0 \leq x \leq 0.5), \quad
85: u(1,x) = 1-x, \ (0.5 \leq x \leq 1)
86: $$
87: $B$GM[E*:9J,K!$rMQ$$$F(B
88: $B;~4V$,(B $0 \leq t \leq \hbox{\it dt}*\hbox{\it step}$ $B$NHO0O$G2r$/(B.
89: @end tex
90: $B6h4V(B [0,1] $B$O(B @code{Heat_N} $B8D$KJ,3d$5$l$k(B.
91: static $BJQ?t(B @code{Heat_N} $B$O(B
92: $B4X?t(B @code{gnuplot.set_heat_N} $B$G@_Dj$9$k(B.
93: $BM-L>$J(B Courant-Friedrichs-Levi $B?t(B
94: @var{dt}*@code{Heat_N}*@code{Heat_N} $B$,(B 0.5 $B0J2<$G$"$l$P(B,
95: $BM[E*:9J,%9%-!<%`$O0BDj$G$"$k(B.
96: CFL $B$rJQ$($k$3$H$K$h$j(B, $BIT0BDj@-$,@8$8$k$N$r4Q;!$G$-$k(B.
97: @example
98: gnuplot.set_heat_N(20); gnuplot.heat(0.001,30); (CFL number is 0.4)
99: gnuplot.set_heat_N(20); gnuplot.heat(0.003,30); (CFL > 0.5 unstable)
100: @end example
101: */
1.4 ! ohara 102: /*&C
1.1 takayama 103: Author of @code{GNUPLOT}: Thomas Williams, Colin Kelley
104: */
105:
1.3 ohara 106: /*&ja
1.1 takayama 107: @section $BH!?t0lMw(B
108: */
1.3 ohara 109: /*&en
1.1 takayama 110: @section Functions
111: */
1.3 ohara 112: /*&ja
1.2 takayama 113: @node gnuplot.start,,, GNUPLOT Functions
1.1 takayama 114: @subsection @code{gnuplot.start}
115: @findex gnuplot.start
116: @table @t
117: @item gnuplot.start()
118: :: Localhost $B$G(B @code{ox_sm1_gnuplot} $B$r5/F0$9$k(B.
119: @end table
120:
121: @table @var
122: @item return
123: $B@0?t(B
124: @end table
125:
126: @itemize @bullet
127: @item Localhost $B$G(B @code{ox_sm1_gnuplot} $B$r5/F0$9$k(B.
128: $B5/F0$5$l$?(B @code{ox_sm1_gnuplot} $B$N<1JLHV9f$rLa$9(B.
129: @item @code{Xm_noX =1} $B$H$7$F$*$/$H(B, @code{ox_sm1_gnuplot} $BMQ$N(B debug window $B$,3+$+$J$$(B.
130: @item $B<1JLHV9f$O(B, @code{Gnuplot_proc} $B$K3JG<$5$l$k(B.
131: @end itemize
132: */
1.3 ohara 133: /*&en
1.1 takayama 134: @node gnuplot.start,,, GNUPLOT Functions
135: @subsection @code{gnuplot.start}
136: @findex gnuplot.start
137: @table @t
138: @item gnuplot.start()
139: :: Start @code{ox_sm1_gnuplot} on the localhost.
140: @end table
141:
142: @table @var
143: @item return
144: Integer
145: @end table
146:
147: @itemize @bullet
148: @item Start @code{ox_sm1_gnuplot} on the localhost.
149: It returns the descriptor of @code{ox_sm1_gnuplot}.
150: @item Set @code{Xm_noX = 1} to start @code{ox_sm1_gnuplot} without a debug window.
151: @item The descriptor is stored in @code{Gnuplot_proc}.
152: @end itemize
153: */
1.4 ! ohara 154: /*&C
1.1 takayama 155: @example
156: P = gnuplot.start();
157: @end example
158: */
1.3 ohara 159: /*&ja
1.1 takayama 160: @table @t
161: @item $B;2>H(B
162: @code{ox_launch}, @code{gnuplot}
163: @end table
164: */
1.3 ohara 165: /*&en
1.1 takayama 166: @table @t
167: @item Reference
168: @code{ox_launch}, @code{gnuplot}
169: @end table
170: */
171:
172:
1.3 ohara 173: /*&en
1.1 takayama 174: @node gnuplot,,, GNUPLOT Functions
175: @subsection @code{gnuplot}
176: @findex gnuplot
177: @table @t
178: @item gnuplot.gnuplot(@var{s}|proc=@var{p})
179: :: Ask GNUPLOT to execute the command string @var{s}.
180: @end table
181:
182: @table @var
183: @item return
184: Void
185: @item p
186: Number
187: @item s
188: String
189: @end table
190:
191: @itemize @bullet
192: @item
193: The server executes the gnuplot command @var{s}.
194: When an error occurs,
195: the gnuplot itself terminates and ox_sm1_gnuplot server automatically
196: restarts gnuplot.
197: @item
198: gnuplot does not accept a long polynomial.
199: @item
200: gnuplot does not accept @code{^}. Use @code{**} instead.
201: @end itemize
202: */
1.3 ohara 203: /*&ja
1.2 takayama 204: @node gnuplot,,, GNUPLOT Functions
1.1 takayama 205: @subsection @code{gnuplot}
206: @findex gnuplot
207: @table @t
208: @item gnuplot.gnuplot(@var{s}|proc=@var{p})
209: :: GNUPLOT $B$K%3%^%s%I(B @var{s} $B$r<B9T$7$F$b$i$&(B.
210: @end table
211:
212: @table @var
213: @item return
214: $B$J$7(B
215: @item p
216: $B?t(B
217: @item s
218: $BJ8;zNs(B
219: @end table
220:
221: @itemize @bullet
222: @item
223: $B%5!<%P$O(B GNUPLOT $B$N%3%^%s%I(B @var{s} $B$r<B9T$9$k(B.
224: $B%(%i!<$,$*$-$?>l9g(B GNUPLOT $BK\BN$O=*N;$7$F$7$^$&$,(B,
225: @code{ox_sm1_gnuplot} $B$O<+F0E*$K(B GNUPLOT $BK\BN$r%j%9%?!<%H$9$k(B.
226: @item
227: GNUPLOT $B$OD9$$B?9`<0$r$?$@$7$/$&$1$D$1$J$$(B.
228: @item
229: GNUPLOT $B$O(B @code{^} $B$r$&$1$D$1$J$$(B. $B$+$o$j$K(B, @code{**} $B$r;H$&(B.
230: @end itemize
231: */
1.4 ! ohara 232: /*&C
1.1 takayama 233: @example
234: [232] P = gnuplot.start();
235: 0
236: *Plot 3 dimensional graph.
237: [233] gnuplot.gnuplot("splot x**2-y**2;"|proc=P);
238: 0
239: *Plot 2 dimensional graph.
240: [234] gnuplot.gnuplot("plot [-pi:pi] [-2:2] cos(x);");
241: 0
242: *Output a graph as a postscript figure.
243: [235] gnuplot.output(|file="hoge.eps");
244: 0
245: [236] gnuplot.gnuplot("plot sin(x)*cos(x);");
246: 0
247: [237] gnuplot.gnuplot(|file="x11");
248: 0
249:
250: *Plot 3 dimensional graph hiding unvisible lines.
251: [236] gnuplot.gnuplot("set hidden3d");
252: 0
253: [237] gnuplot.gnuplot("splot (x**2+y**2)*sin(x**2+y**2)");
254: 0
255: [238] gnuplot.gnuplot("set isosamples 50");
256: 0
257: [239] gnuplot.gnuplot("splot (x**2+y**2)*sin(x**2+y**2)");
258:
259: @end example
260: */
1.3 ohara 261: /*&en
1.1 takayama 262: @table @t
263: @item Reference
264: @code{ox_launch}, @code{gnuplot.start}, @code{rtostr},
265: @code{gnuplot.plot_dots}
266: @item Reference Book
267: Yabuki Michiro, Otake Tuyoshi; Tukai konasu GNUPLOT, Techno Press,
268: in Japansese, ISBN4-924998-11-7
269: @end table
270: */
1.3 ohara 271: /*&ja
1.1 takayama 272: @table @t
273: @item $B;2>H(B
274: @code{ox_launch}, @code{gnuplot.start}, @code{rtostr},
275: @code{gnuplot.plot_dots}
276: @item $B;29M=q(B
277: $BLp?aF;O:(B, $BBgC]$D$h$7(B; $B;H$$$3$J$9(B GNUPLOT, $B%F%/%N%W%l%9(B,
278: ISBN4-924998-11-7
279: @end table
280: */
281:
282:
283:
1.3 ohara 284: /*&en
1.1 takayama 285: @node gnuplot.plot_dots,,, GNUPLOT Functions
286: @subsection @code{gnuplot.plot_dots}
287: @findex gnuplot.plot_dots
288: @table @t
289: @item gnuplot.plot_dots(@var{d},@var{s}|proc=@var{p})
290: :: Plot the dots @var{d} with the style @var{s}.
291: @end table
292:
293: @table @var
294: @item return
295: Void
296: @item p
297: Number
298: @item d
299: List
300: @item s
301: String or 0
302: @end table
303:
304: @itemize @bullet
305: @item
306: Plot the dots @var{d} with the style @var{s}.
307: @var{s} is a string of the form
308: "style color point".
309: Here,
310: style can be lines, points, linespoints, impulses, dots, steps,
311: errorbars, boxes, boxerrorbars.
312: color can be 1 (red), 2 (green), 3 (blue), 4, ... , 8.
313: point can be a number from 1 to 8.
314: The color and point field can be omitted.
315: @item
316: When @var{d} == @code{[ ]}, the screen will be cleared.
317: @end itemize
318: */
1.3 ohara 319: /*&ja
1.2 takayama 320: @node gnuplot.plot_dots,,, GNUPLOT Functions
1.1 takayama 321: @subsection @code{gnuplot.plot_dots}
322: @findex gnuplot.plot_dots
323: @table @t
324: @item gnuplot.plot_dots(@var{d},@var{s}|proc=@var{p})
325: :: $BE@$N=89g(B @var{d} $B$r%9%?%$%k(B @var{s} $B$G%W%m%C%H$9$k(B.
326: @end table
327:
328: @table @var
329: @item return
330: $B$J$7(B
331: @item p
332: $B?t(B
333: @item d
334: $B%j%9%H(B
335: @item s
336: $BJ8;zNs(B $B$^$?$O(B 0
337: @end table
338:
339: @itemize @bullet
340: @item
341: $BE@=89g(B @var{d} $B$r%9%?%$%k(B @var{s} $B$G%W%m%C%H$9$k(B.
342: @var{s} $B$O<!$N$h$&$JJ8;zNs(B:
343: "style color point".
344: $B$3$3$G(B
345: style $B$K$O(B lines, points, linespoints, impulses, dots, steps,
346: errorbars, boxes, boxerrorbars
347: $B$rA*$Y$k(B.
348: color $B$K$O(B 1 (red), 2 (green), 3 (blue), 4, ... , 8
349: $B$rA*$Y$k(B.
350: point $B$O(B 1 $B$+$i(B 8 $B$N?t$rF~$l$k(B.
351: color, point $B$O>JN,$7$F$h$$(B.
352: @item
353: @var{d} == @code{[ ]} $B$N$H$-$O%9%/%j!<%s$,$^$:>C5n$5$l$k(B.
354: @end itemize
355: */
1.4 ! ohara 356: /*&C
1.1 takayama 357: @example
358: [239] P = gnuplot.start();
359: 0
360: [240] gnuplot.plot_dots([ ],0);
361: 0
362: [241] for (I=0; I<10; I++) gnuplot.plot_dots([[I,I^2]]," lines ");
363: [242] A = [ ];
364: []
365: [243] for (I=0; I<10; I++) A = append(A,[ [I,I^2]]);
366: [244] A;
367: [[0,0],[1,1],[2,4],[3,9],[4,16],[5,25],[6,36],[7,49],[8,64],[9,81]]
368: [245] gnuplot.plot_dots(A," lines ");
369: 0
370: @end example
371: */
1.3 ohara 372: /*&ja
1.1 takayama 373: @table @t
374: @item $B;2>H(B
375: @code{gnuplot.start}, @code{plot "fileName" with options}(GNUPLOT command),
376: @code{gnuplot.clean}, @code{gnuplot}
377: @end table
378: */
1.3 ohara 379: /*&en
1.1 takayama 380: @table @t
381: @item Reference
382: @code{gnuplot.start}, @code{plot "fileName" with options}(GNUPLOT command),
383: @code{gnuplot.clean}, @code{gnuplot}
384: @end table
385: */
386:
387:
388:
389: /** heat equation **/
390:
1.3 ohara 391: /*&en
1.1 takayama 392: @node gnuplot.heat,,, GNUPLOT Functions
393: @subsection @code{gnuplot.heat}
394: @findex gnuplot.heat
395: @table @t
396: @item gnuplot.heat(@var{dt},@var{step})
397: :: It solves the heat equation numerical and plots solutions
398: @end table
399:
400: @table @var
401: @item return
402: Void
403: @item dt
404: floating point number
405: @item step
406: Integer
407: @end table
408:
409: @itemize @bullet
410: @item It solves the heat equation
411: du/dt = d^2 u/dx^2, u(t,0) = u(t,1) = 0
412: with the initial condition
413: u(0,x) = x (0 <= x <= 0.5), u(0,x) = 1-x ( 0.5 <= x <= 1.0).
414: @item Heat_N is the number of the meshes in the space.
415: @item This function will be called @code{pde_heat_demo} in a future.
416: @end itemize
417:
418: @noindent
419: Algorithm: NOT Written. (Difference scheme. Courant-Levi-Friedrichs conditions.)
420: */
1.3 ohara 421: /*&ja
1.2 takayama 422: @node gnuplot.heat,,, GNUPLOT Functions
1.1 takayama 423: @subsection @code{gnuplot.heat}
424: @findex gnuplot.heat
425: @table @t
426: @item gnuplot.heat(@var{dt},@var{step})
427: :: $BG.EAF3J}Dx<0$r?tCME*$K2r$/(B.
428: @end table
429:
430: @table @var
431: @item return
432: $B$J$7(B
433: @item dt
434: $BIbF0>.?tE@?t(B
435: @item step
436: $B@0?t(B
437: @end table
438:
439: @itemize @bullet
440: @item $BG.EAF3J}Dx<0(B
441: du/dt = d^2 u/dx^2, u(t,0) = u(t,1) = 0
442: $B$r=i4|>r7o(B
443: u(0,x) = x (0 <= x <= 0.5), u(0,x) = 1-x ( 0.5 <= x <= 1.0)
444: $B$G2r$/(B.
445: @item Heat_N $B$O6u4VJ}8~$G$N%a%C%7%e$N?t(B.
446: @item $B$3$N4X?t$O>-Mh(B @code{pde_heat_demo} $B$H8F$P$l$kM=Dj(B.
447: @end itemize
448: */
1.4 ! ohara 449: /*&C
1.1 takayama 450: @example
451: [232] Heat_N = 20$
452: [233] gnuplot.heat(0.001,30)$
453: @end example
454:
455: */
456:
457:
458:
1.3 ohara 459: /*&en
1.1 takayama 460: @node gnuplot.output,,, GNUPLOT Functions
461: @subsection @code{gnuplot.output}
462: @findex gnuplot.output
463: @table @t
464: @item gnuplot.output(|@var{file=s})
465: :: ask @code{GNUPLOT} to output graphic to the file @var{s} in the Postscript format.
466: @end table
467:
468: @table @var
469: @item return
470: Void
471: @item s
472: String
473: @end table
474:
475: @itemize @bullet
476: @item ask @code{GNUPLOT} to output graphic to the file @var{s} in the Postscript format.
477: @item When @code{s} is "x11" or this function is called without the argument,
478: the output will be written to X11 display.
479: @end itemize
480: */
1.3 ohara 481: /*&ja
1.2 takayama 482: @node gnuplot.output,,, GNUPLOT Functions
1.1 takayama 483: @subsection @code{gnuplot.output}
484: @findex gnuplot.output
485: @table @t
486: @item gnuplot.output(|@var{file=s})
487: :: @code{GNUPLOT} $B$K%U%!%$%k(B @var{s} $B$X%]%9%H%9%/%j%W%H$G=PNO$9$k$h$&$KMj$`(B.
488: @end table
489:
490: @table @var
491: @item return
492: Void
493: @item s
494: String
495: @end table
496:
497: @itemize @bullet
498: @item @code{GNUPLOT} $B$K%U%!%$%k(B @var{s} $B$X%]%9%H%9%/%j%W%H$G=PNO$9$k$h$&$KMj$`(B.
499: @item @code{s} $B$,(B "x11" $B$^$?$O(B, $B$3$N4X?t$r0z?tL5$7$G$h$V$H(B,
500: $B0J8e(B, X11 $B$N(B display $B$K(B graphics $B$,=PNO$5$l$k(B.
501: @end itemize
502: */
503:
1.4 ! ohara 504: /*&C
1.1 takayama 505: @example
506: [273] gnuplot.output(|file="hoge.eps");
507: Graphic output of GNUPLOT will be written to hoge.eps as a Poscript file.
508: 0
509: [274] gnuplot.gnuplot("plot tan(x)+sin(x);");
510: 0
511: [275] gnuplot.output();
512: Usage of gnuplot.output: gnuplot.output(|file="string")
513: gnuplot.output(|file="x11")
514: Output device is set to X11
515: @end example
516: */
517:
1.3 ohara 518: /*&en
1.1 takayama 519: @table @t
520: @item Reference
521: @code{gnuplot}
522: @end table
523: */
1.3 ohara 524: /*&ja
1.1 takayama 525: @table @t
526: @item $B;2>H(B
527: @code{gnuplot}
528: @end table
529: */
530:
531:
1.3 ohara 532: /*&en
1.1 takayama 533: @node gnuplot.plot_function,,, GNUPLOT Functions
534: @subsection @code{gnuplot.plot_function}
535: @findex gnuplot.plot_function
536: @table @t
537: @item gnuplot.gnuplot(@var{f}|proc=@var{p})
538: :: ask the @code{gnuplot} server to draw a graph of @var{f}
539: @end table
540:
541: @table @var
542: @item return
543: Void
544: @item p
545: Number
546: @item f
547: Polynomial or a list of polynomials
548: @end table
549:
550: @itemize @bullet
551: @item ask the @code{gnuplot} server to draw a graph of @var{f}
552: @end itemize
553: */
554:
1.3 ohara 555: /*&ja
1.2 takayama 556: @node gnuplot.plot_function,,, GNUPLOT Functions
1.1 takayama 557: @subsection @code{gnuplot.plot_function}
558: @findex gnuplot.plot_function
559: @table @t
1.2 takayama 560: @item gnuplot.plot_function(@var{f}|proc=@var{p})
1.1 takayama 561: :: @code{gnuplot} $B%5!<%P$K(B @var{f} $B$N%0%i%U$r=q$/$h$&$KMj$`(B.
562: @end table
563:
564: @table @var
565: @item $BLa$jCM(B
566: $B$J$7(B
567: @item p
568: $B?t(B
569: @item f
570: $BB?9`<0$^$?$OB?9`<0$N%j%9%H(B
571: @end table
572:
573: @itemize @bullet
574: @item @code{gnuplot} $B%5!<%P$K(B @var{f} $B$N%0%i%U$r=q$/$h$&$KMj$`(B.
575: @end itemize
576: */
1.4 ! ohara 577: /*&C
1.1 takayama 578:
579: @example
580: [290] gnuplot.plot_function((x+sin(x))^2);
581: 0
582: [291] gnuplot.plot_function([x,x^2,x^3]);
583: 0
584: @end example
585:
586: */
587:
1.3 ohara 588: /*&en
1.1 takayama 589: @table @t
590: @item Reference
591: @code{gnuplot.to_gnuplot_format}
592: @end table
593: */
1.3 ohara 594: /*&ja
1.1 takayama 595: @table @t
596: @item $B;2>H(B
597: @code{gnuplot.to_gnuplot_format}
598: @end table
599: */
600:
601:
602: end$
603:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>