1540
|
1 # Copyright (C) 1995 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 the |
|
7 # Free Software Foundation; either version 2, or (at your option) any |
|
8 # later version. |
|
9 # |
|
10 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 # 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. |
|
19 |
|
20 function multiplot (xn, yn) |
|
21 |
|
22 # usage: multiplot (xn, yn) |
|
23 # |
|
24 # Sets and resets multiplot mode |
|
25 # |
|
26 # If multiplot(0,0) then it will close multiplot mode and and if |
|
27 # arguments are non-zero, then it will set up multiplot mode with |
|
28 # xn,yn subplots along x and y axes. |
|
29 # |
|
30 # NOTE: this will work only with gnuplot installed with |
|
31 # multiplot patch |
|
32 |
|
33 # Written by Vinayak Dutt, Dutt.Vinayak@mayo.EDU 3 Jul 95 |
|
34 |
|
35 # global variables to keep track of multiplot options |
|
36 |
|
37 global multiplot_mode |
1541
|
38 global multiplot_xsize multiplot_ysize |
|
39 global multiplot_xn multiplot_yn |
|
40 global multiplot_xi multiplot_yi |
1540
|
41 |
|
42 # This is a real kludge. We gnuplot should be made so that replot can |
|
43 # be executed while doing multiple plots... |
|
44 |
|
45 global multiplot_save_auto_replot = automatic_replot |
|
46 |
|
47 if (nargin != 2) |
|
48 usage ("multiplot (xn, yn)"); |
|
49 endif |
|
50 |
|
51 if (! (is_scalar (xn) && is_scalar (yn))) |
|
52 error ("multiplot: xn and yn have to be scalars"); |
|
53 endif |
|
54 |
|
55 if ((isstr (automatic_replot) && strcmp (automatic_replot,"true")) |
|
56 || automatic_replot) |
|
57 warning ("turning off automatic replot for multiplot mode"); |
|
58 multiplot_save_auto_replot = automatic_replot; |
|
59 automatic_replot = 0; |
|
60 endif |
|
61 |
|
62 xn = round (xn); |
|
63 yn = round (yn); |
|
64 |
|
65 if (xn == 0 && yn == 0) |
|
66 |
|
67 set nomultiplot; |
1557
|
68 set size 1, 1; |
|
69 set origin 0, 0; |
1540
|
70 |
|
71 multiplot_mode = 0; |
1541
|
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 # Someone may have reset it betweeen calls... |
|
80 |
|
81 if (! isstr (automatic_replot) && ! automatic_replot) |
|
82 automatic_replot = multiplot_save_auto_replot; |
|
83 endif |
|
84 |
|
85 return; |
|
86 |
|
87 else |
|
88 |
|
89 if (xn < 1 || yn < 1) |
|
90 error ("multiplot: xn and yn have to be positive integers"); |
|
91 endif |
|
92 |
|
93 set multiplot; |
|
94 |
|
95 xsize = 1.0 ./ xn; |
|
96 ysize = 1.0 ./ yn; |
|
97 |
|
98 eval (sprintf ("set size %g, %g", xsize, ysize)); |
|
99 |
|
100 xo = 0.0; |
|
101 yo = (yn - 1.0)*ysize; |
|
102 |
|
103 eval (sprintf ("set origin %g, %g", xo, yo)); |
|
104 |
|
105 multiplot_mode = 1; |
1541
|
106 multiplot_xsize = xsize; |
|
107 multiplot_ysize = ysize; |
|
108 multiplot_xn = xn; |
|
109 multiplot_yn = yn; |
|
110 multiplot_xi = 1; |
|
111 multiplot_yi = 1; |
1540
|
112 |
|
113 endif |
|
114 |
|
115 endfunction |