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 |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
245
|
19 |
3449
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} __plt__ (@code{caller}, @dots{}) |
|
22 ## @end deftypefn |
3402
|
23 |
2314
|
24 ## Author: jwe |
|
25 |
6302
|
26 function retval = __plt__ (caller, h, varargin) |
5406
|
27 |
6257
|
28 nargs = nargin - 2; |
6146
|
29 |
6257
|
30 if (nargs > 0) |
934
|
31 |
5116
|
32 k = 1; |
5119
|
33 |
|
34 x_set = false; |
|
35 y_set = false; |
6459
|
36 property_set = false; |
|
37 properties = {}; |
934
|
38 |
5116
|
39 ## Gather arguments, decode format, gather plot strings, and plot lines. |
934
|
40 |
6405
|
41 retval = []; |
|
42 |
6257
|
43 while (nargs > 0 || x_set) |
5115
|
44 |
5119
|
45 if (nargs == 0) |
|
46 ## Force the last plot when input variables run out. |
6459
|
47 next_cell = {}; |
6146
|
48 next_arg = {""}; |
5118
|
49 else |
6459
|
50 next_cell = varargin(k); |
5119
|
51 next_arg = varargin{k++}; |
5116
|
52 endif |
934
|
53 |
6257
|
54 nargs--; |
|
55 |
6146
|
56 if (ischar (next_arg) || iscellstr (next_arg)) |
5119
|
57 if (x_set) |
6459
|
58 [options, valid] = __pltopt__ (caller, next_arg, false); |
|
59 if (! valid) |
|
60 if (nargs == 0) |
|
61 error ("%s: properties must appear followed by a value", caller); |
|
62 endif |
|
63 properties = [properties, [next_cell, varargin(k++)]]; |
|
64 nargs--; |
|
65 continue; |
|
66 else |
|
67 while (nargs > 0 && ischar (varargin{k})) |
|
68 if (nargs < 2) |
|
69 error ("%s: properties must appear followed by a value", |
|
70 caller); |
|
71 endif |
|
72 properties = [properties, varargin(k:k+1)]; |
|
73 k += 2; |
|
74 nargs -= 2; |
|
75 endwhile |
|
76 endif |
5119
|
77 if (y_set) |
6459
|
78 tmp = __plt2__ (h, x, y, options, properties); |
|
79 properties = {}; |
6405
|
80 retval = [retval; tmp]; |
5119
|
81 else |
6459
|
82 tmp = __plt1__ (h, x, options, properties); |
|
83 properties = {}; |
6405
|
84 retval = [retval; tmp]; |
5741
|
85 endif |
5119
|
86 x_set = false; |
|
87 y_set = false; |
|
88 else |
5116
|
89 error ("plot: no data to plot"); |
|
90 endif |
|
91 elseif (x_set) |
|
92 if (y_set) |
6264
|
93 options = __pltopt__ (caller, {""}); |
6459
|
94 tmp = __plt2__ (h, x, y, options, properties); |
6405
|
95 retval = [retval; tmp]; |
5119
|
96 x = next_arg; |
|
97 y_set = false; |
6459
|
98 properties = {}; |
5116
|
99 else |
5119
|
100 y = next_arg; |
|
101 y_set = true; |
5116
|
102 endif |
|
103 else |
5119
|
104 x = next_arg; |
|
105 x_set = true; |
4
|
106 endif |
934
|
107 |
5118
|
108 endwhile |
934
|
109 |
4
|
110 else |
5119
|
111 msg = sprintf ("%s (y)\n", caller); |
|
112 msg = sprintf ("%s %s (x, y, ...)\n", msg, caller); |
|
113 msg = sprintf ("%s %s (x, y, fmt, ...)", msg, caller); |
6459
|
114 msg = sprintf ("%s %s (x, y, property, value, ...)", msg, caller); |
934
|
115 usage (msg); |
4
|
116 endif |
|
117 |
6004
|
118 endfunction |
6459
|
119 |