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