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 |
|
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|
18 ## 02111-1307, 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 |
2296
|
36 if (! gnuplot_has_multiplot) |
|
37 error ("multiplot: gnuplot does not appear to support this feature"); |
|
38 endif |
2325
|
39 |
2303
|
40 ## global variables to keep track of multiplot options |
1540
|
41 |
3106
|
42 global __multiplot_mode__ = 0; |
|
43 global __multiplot_xsize__; |
|
44 global __multiplot_ysize__; |
|
45 global __multiplot_xn__; |
|
46 global __multiplot_yn__; |
|
47 global __multiplot_xi__; |
|
48 global __multiplot_yi__; |
1540
|
49 |
|
50 if (nargin != 2) |
|
51 usage ("multiplot (xn, yn)"); |
|
52 endif |
|
53 |
|
54 if (! (is_scalar (xn) && is_scalar (yn))) |
|
55 error ("multiplot: xn and yn have to be scalars"); |
|
56 endif |
|
57 |
|
58 xn = round (xn); |
|
59 yn = round (yn); |
|
60 |
|
61 if (xn == 0 && yn == 0) |
|
62 |
3103
|
63 oneplot (); |
|
64 |
|
65 ## XXX FIXME XXX -- do we really need to reset these here? |
1540
|
66 |
3103
|
67 __multiplot_xsize__ = 1; |
|
68 __multiplot_ysize__ = 1; |
|
69 __multiplot_xn__ = 1; |
|
70 __multiplot_yn__ = 1; |
|
71 __multiplot_xi__ = 1; |
|
72 __multiplot_yi__ = 1; |
1540
|
73 |
|
74 else |
|
75 |
|
76 if (xn < 1 || yn < 1) |
|
77 error ("multiplot: xn and yn have to be positive integers"); |
|
78 endif |
|
79 |
2520
|
80 gset multiplot; |
1540
|
81 |
|
82 xsize = 1.0 ./ xn; |
|
83 ysize = 1.0 ./ yn; |
|
84 |
2520
|
85 eval (sprintf ("gset size %g, %g", xsize, ysize)); |
1540
|
86 |
|
87 xo = 0.0; |
|
88 yo = (yn - 1.0)*ysize; |
|
89 |
2520
|
90 eval (sprintf ("gset origin %g, %g", xo, yo)); |
1540
|
91 |
3103
|
92 __multiplot_mode__ = 1; |
|
93 __multiplot_xsize__ = xsize; |
|
94 __multiplot_ysize__ = ysize; |
|
95 __multiplot_xn__ = xn; |
|
96 __multiplot_yn__ = yn; |
|
97 __multiplot_xi__ = 1; |
|
98 __multiplot_yi__ = 1; |
1540
|
99 |
3162
|
100 gnuplot_command_replot = "cle;rep"; |
|
101 |
3156
|
102 clearplot; |
|
103 |
1540
|
104 endif |
|
105 |
|
106 endfunction |