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