2313
|
1 ## Copyright (C) 1996 John W. Eaton |
|
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 |
|
26 ## xn,yn subplots along x and y axes. |
|
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 |
|
40 |
2303
|
41 ## global variables to keep track of multiplot options |
1540
|
42 |
|
43 global multiplot_mode |
1541
|
44 global multiplot_xsize multiplot_ysize |
|
45 global multiplot_xn multiplot_yn |
|
46 global multiplot_xi multiplot_yi |
1540
|
47 |
2303
|
48 ## This is a real kludge. We gnuplot should be made so that replot can |
|
49 ## be executed while doing multiple plots... |
1540
|
50 |
|
51 global multiplot_save_auto_replot = automatic_replot |
|
52 |
|
53 if (nargin != 2) |
|
54 usage ("multiplot (xn, yn)"); |
|
55 endif |
|
56 |
|
57 if (! (is_scalar (xn) && is_scalar (yn))) |
|
58 error ("multiplot: xn and yn have to be scalars"); |
|
59 endif |
|
60 |
|
61 if ((isstr (automatic_replot) && strcmp (automatic_replot,"true")) |
|
62 || automatic_replot) |
|
63 warning ("turning off automatic replot for multiplot mode"); |
|
64 multiplot_save_auto_replot = automatic_replot; |
|
65 automatic_replot = 0; |
|
66 endif |
|
67 |
|
68 xn = round (xn); |
|
69 yn = round (yn); |
|
70 |
|
71 if (xn == 0 && yn == 0) |
|
72 |
|
73 set nomultiplot; |
1557
|
74 set size 1, 1; |
|
75 set origin 0, 0; |
1540
|
76 |
|
77 multiplot_mode = 0; |
1541
|
78 multiplot_xsize = 1; |
|
79 multiplot_ysize = 1; |
|
80 multiplot_xn = 1; |
|
81 multiplot_yn = 1; |
|
82 multiplot_xi = 1; |
|
83 multiplot_yi = 1; |
1540
|
84 |
2303
|
85 ## Someone may have reset it betweeen calls... |
1540
|
86 |
|
87 if (! isstr (automatic_replot) && ! automatic_replot) |
|
88 automatic_replot = multiplot_save_auto_replot; |
|
89 endif |
|
90 |
|
91 return; |
|
92 |
|
93 else |
|
94 |
|
95 if (xn < 1 || yn < 1) |
|
96 error ("multiplot: xn and yn have to be positive integers"); |
|
97 endif |
|
98 |
|
99 set multiplot; |
|
100 |
|
101 xsize = 1.0 ./ xn; |
|
102 ysize = 1.0 ./ yn; |
|
103 |
|
104 eval (sprintf ("set size %g, %g", xsize, ysize)); |
|
105 |
|
106 xo = 0.0; |
|
107 yo = (yn - 1.0)*ysize; |
|
108 |
|
109 eval (sprintf ("set origin %g, %g", xo, yo)); |
|
110 |
|
111 multiplot_mode = 1; |
1541
|
112 multiplot_xsize = xsize; |
|
113 multiplot_ysize = ysize; |
|
114 multiplot_xn = xn; |
|
115 multiplot_yn = yn; |
|
116 multiplot_xi = 1; |
|
117 multiplot_yi = 1; |
1540
|
118 |
|
119 endif |
|
120 |
|
121 endfunction |