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} {} subwindow (@var{xn}, @var{yn}) |
|
22 ## Sets the subwindow position in multiplot mode for the next plot. The |
|
23 ## multiplot mode has to be previously initialized using the |
|
24 ## @code{multiplot} function, otherwise this command just becomes an alias |
|
25 ## to @code{multiplot} |
|
26 ## @end deftypefn |
1540
|
27 |
2312
|
28 ## Author: Vinayak Dutt <Dutt.Vinayak@mayo.EDU> |
|
29 ## Created: 3 July 95 |
|
30 ## Adapted-By: jwe |
1540
|
31 |
2312
|
32 function subwindow (xn, yn) |
1540
|
33 |
2303
|
34 ## global variables to keep track of multiplot options |
1540
|
35 |
3106
|
36 global __multiplot_mode__ = 0; |
|
37 global __multiplot_xsize__; |
|
38 global __multiplot_ysize__; |
|
39 global __multiplot_xn__; |
|
40 global __multiplot_yn__; |
1540
|
41 |
2303
|
42 ## check calling argument count |
1540
|
43 |
|
44 if (nargin != 2) |
|
45 usage ("subwindow (xn, yn)"); |
|
46 endif |
|
47 |
2303
|
48 ## check for scalar inputs |
1540
|
49 |
4030
|
50 if (! (isscalar (xn) && isscalar (yn))) |
1540
|
51 error ("subwindow: xn and yn have to be scalars"); |
|
52 endif |
|
53 |
|
54 xn = round (xn); |
|
55 yn = round (yn); |
|
56 |
2303
|
57 ## switch to multiplot mode if not already in, and use the args as the |
2325
|
58 ## args to multiplot() |
1540
|
59 |
3103
|
60 if (! __multiplot_mode__) |
1557
|
61 multiplot (xn, yn); |
1540
|
62 return; |
|
63 endif |
|
64 |
2303
|
65 ## get the sub plot location |
1540
|
66 |
3103
|
67 if (xn < 1 || xn > __multiplot_xn__ || yn < 1 || yn > __multiplot_yn__) |
1540
|
68 error ("subwindow: incorrect xn and yn"); |
|
69 endif |
|
70 |
3103
|
71 xo = (xn - 1.0) * __multiplot_xsize__; |
|
72 yo = (__multiplot_yn__ - yn) * __multiplot_ysize__; |
1540
|
73 |
2520
|
74 eval (sprintf ("gset origin %g, %g", xo, yo)); |
2325
|
75 |
3156
|
76 clearplot; |
|
77 |
1540
|
78 endfunction |