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 |
2311
|
20 ## usage: multiplot (xn, yn) |
|
21 ## |
|
22 ## Sets and resets multiplot mode |
|
23 ## |
|
24 ## If multiplot(0,0) then it will close multiplot mode and and if |
|
25 ## arguments are non-zero, then it will set up multiplot mode with |
2325
|
26 ## xn,yn subplots along x and y axes. |
2311
|
27 ## |
|
28 ## NOTE: this will work only with gnuplot installed with |
|
29 ## multiplot patch |
1540
|
30 |
2312
|
31 ## Author: Vinayak Dutt, Dutt.Vinayak@mayo.EDU |
|
32 ## Created: 3 July 95 |
|
33 ## Adapted-By: jwe |
1540
|
34 |
2312
|
35 function multiplot (xn, yn) |
1540
|
36 |
2296
|
37 if (! gnuplot_has_multiplot) |
|
38 error ("multiplot: gnuplot does not appear to support this feature"); |
|
39 endif |
2325
|
40 |
2303
|
41 ## global variables to keep track of multiplot options |
1540
|
42 |
3103
|
43 global __multiplot_mode__ |
|
44 global __multiplot_xsize__ |
|
45 global __multiplot_ysize__ |
|
46 global __multiplot_xn__ |
|
47 global __multiplot_yn__ |
|
48 global __multiplot_xi__ |
|
49 global __multiplot_yi__ |
1540
|
50 |
3103
|
51 if (! exist ("__multiplot_mode__")) |
|
52 __multiplot_mode__ = 0; |
|
53 endif |
1540
|
54 |
|
55 if (nargin != 2) |
|
56 usage ("multiplot (xn, yn)"); |
|
57 endif |
|
58 |
|
59 if (! (is_scalar (xn) && is_scalar (yn))) |
|
60 error ("multiplot: xn and yn have to be scalars"); |
|
61 endif |
|
62 |
|
63 xn = round (xn); |
|
64 yn = round (yn); |
|
65 |
|
66 if (xn == 0 && yn == 0) |
|
67 |
3103
|
68 oneplot (); |
|
69 |
|
70 ## XXX FIXME XXX -- do we really need to reset these here? |
1540
|
71 |
3103
|
72 __multiplot_xsize__ = 1; |
|
73 __multiplot_ysize__ = 1; |
|
74 __multiplot_xn__ = 1; |
|
75 __multiplot_yn__ = 1; |
|
76 __multiplot_xi__ = 1; |
|
77 __multiplot_yi__ = 1; |
1540
|
78 |
|
79 else |
|
80 |
|
81 if (xn < 1 || yn < 1) |
|
82 error ("multiplot: xn and yn have to be positive integers"); |
|
83 endif |
|
84 |
2520
|
85 gset multiplot; |
1540
|
86 |
|
87 xsize = 1.0 ./ xn; |
|
88 ysize = 1.0 ./ yn; |
|
89 |
2520
|
90 eval (sprintf ("gset size %g, %g", xsize, ysize)); |
1540
|
91 |
|
92 xo = 0.0; |
|
93 yo = (yn - 1.0)*ysize; |
|
94 |
2520
|
95 eval (sprintf ("gset origin %g, %g", xo, yo)); |
1540
|
96 |
3103
|
97 __multiplot_mode__ = 1; |
|
98 __multiplot_xsize__ = xsize; |
|
99 __multiplot_ysize__ = ysize; |
|
100 __multiplot_xn__ = xn; |
|
101 __multiplot_yn__ = yn; |
|
102 __multiplot_xi__ = 1; |
|
103 __multiplot_yi__ = 1; |
1540
|
104 |
|
105 endif |
|
106 |
|
107 endfunction |