2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
1540
|
19 |
3368
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} multiplot (@var{xn}, @var{yn}) |
|
22 ## Sets and resets multiplot mode. |
3426
|
23 ## |
3368
|
24 ## If the arguments are non-zero, @code{multiplot} will set up multiplot |
|
25 ## mode with @var{xn}, @var{yn} subplots along the @var{x} and @var{y} |
|
26 ## axes. If both arguments are zero, @code{multiplot} closes multiplot |
|
27 ## mode. |
|
28 ## @end deftypefn |
1540
|
29 |
2312
|
30 ## Author: Vinayak Dutt, Dutt.Vinayak@mayo.EDU |
|
31 ## Created: 3 July 95 |
|
32 ## Adapted-By: jwe |
1540
|
33 |
2312
|
34 function multiplot (xn, yn) |
1540
|
35 |
2303
|
36 ## global variables to keep track of multiplot options |
1540
|
37 |
3106
|
38 global __multiplot_mode__ = 0; |
|
39 global __multiplot_xsize__; |
|
40 global __multiplot_ysize__; |
|
41 global __multiplot_xn__; |
|
42 global __multiplot_yn__; |
|
43 global __multiplot_xi__; |
|
44 global __multiplot_yi__; |
1540
|
45 |
|
46 if (nargin != 2) |
|
47 usage ("multiplot (xn, yn)"); |
|
48 endif |
|
49 |
4030
|
50 if (! (isscalar (xn) && isscalar (yn))) |
1540
|
51 error ("multiplot: xn and yn have to be scalars"); |
|
52 endif |
|
53 |
|
54 xn = round (xn); |
|
55 yn = round (yn); |
|
56 |
|
57 if (xn == 0 && yn == 0) |
|
58 |
3103
|
59 oneplot (); |
|
60 |
|
61 ## XXX FIXME XXX -- do we really need to reset these here? |
1540
|
62 |
3103
|
63 __multiplot_xsize__ = 1; |
|
64 __multiplot_ysize__ = 1; |
|
65 __multiplot_xn__ = 1; |
|
66 __multiplot_yn__ = 1; |
|
67 __multiplot_xi__ = 1; |
|
68 __multiplot_yi__ = 1; |
1540
|
69 |
|
70 else |
|
71 |
|
72 if (xn < 1 || yn < 1) |
|
73 error ("multiplot: xn and yn have to be positive integers"); |
|
74 endif |
|
75 |
5252
|
76 __gnuplot_raw__ ("set multiplot;\n"); |
1540
|
77 |
|
78 xsize = 1.0 ./ xn; |
|
79 ysize = 1.0 ./ yn; |
|
80 |
5252
|
81 __gnuplot_raw__ (sprintf ("set size %g, %g;\n", xsize, ysize)); |
1540
|
82 |
|
83 xo = 0.0; |
|
84 yo = (yn - 1.0)*ysize; |
|
85 |
5252
|
86 __gnuplot_raw__ (sprintf ("set origin %g, %g;\n", xo, yo)); |
1540
|
87 |
3103
|
88 __multiplot_mode__ = 1; |
|
89 __multiplot_xsize__ = xsize; |
|
90 __multiplot_ysize__ = ysize; |
|
91 __multiplot_xn__ = xn; |
|
92 __multiplot_yn__ = yn; |
|
93 __multiplot_xi__ = 1; |
|
94 __multiplot_yi__ = 1; |
1540
|
95 |
3162
|
96 gnuplot_command_replot = "cle;rep"; |
|
97 |
3156
|
98 clearplot; |
|
99 |
1540
|
100 endif |
|
101 |
|
102 endfunction |