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. |
245
|
19 |
3449
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} __plt__ (@code{caller}, @dots{}) |
|
22 ## @end deftypefn |
3402
|
23 |
2314
|
24 ## Author: jwe |
|
25 |
3979
|
26 function __plt__ (caller, varargin) |
934
|
27 |
4717
|
28 nargs = nargin (); |
|
29 |
5115
|
30 if (nargs >= 2) |
934
|
31 |
5116
|
32 k = 1; |
|
33 j = 1; |
|
34 x = varargin{k++}; |
|
35 nargs -= 2; |
|
36 x_set = 1; |
|
37 y_set = 0; |
|
38 gp_cmd = "gplot"; |
|
39 have_gp_cmd = false; |
5117
|
40 fmt = ""; |
|
41 sep = ""; |
934
|
42 |
5116
|
43 ## Gather arguments, decode format, gather plot strings, and plot lines. |
934
|
44 |
5116
|
45 while (nargs-- > 0) |
4
|
46 |
5116
|
47 new = varargin{k++}; |
5115
|
48 |
5116
|
49 if (j > 1) |
|
50 sep = ",\\\n"; |
|
51 endif |
934
|
52 |
5116
|
53 if (isstr (new)) |
|
54 if (! x_set) |
|
55 error ("plot: no data to plot"); |
|
56 endif |
|
57 fmt = __pltopt__ (caller, new); |
|
58 if (! y_set) |
|
59 [data{j}, fmtstr] = __plt1__ (x, fmt); |
|
60 else |
|
61 [data{j}, fmtstr] = __plt2__ (x, y, fmt); |
|
62 endif |
5115
|
63 if (iscell (data{j})) |
|
64 for i = 1:length (data{j}) |
|
65 gp_cmd = sprintf ("%s%s data{%d}{%d} %s", gp_cmd, sep, |
|
66 j, i, fmtstr{i}); |
|
67 sep = ",\\\n"; |
|
68 have_gp_cmd = true; |
|
69 endfor |
|
70 else |
|
71 gp_cmd = sprintf ("%s%s data{%d} %s", gp_cmd, sep, j++, fmtstr); |
|
72 have_gp_cmd = true; |
5116
|
73 endif |
|
74 x_set = 0; |
|
75 y_set = 0; |
|
76 elseif (x_set) |
|
77 if (y_set) |
|
78 [data{j}, fmtstr] = __plt2__ (x, y, fmt); |
|
79 if (iscell (data{j})) |
|
80 for i = 1:length (data{j}) |
|
81 gp_cmd = sprintf ("%s%s data{%d}{%d} %s", gp_cmd, sep, |
|
82 j, i, fmtstr{i}); |
|
83 sep = ",\\\n"; |
|
84 have_gp_cmd = true; |
|
85 endfor |
|
86 else |
|
87 gp_cmd = sprintf ("%s%s data{%d} %s", gp_cmd, sep, j++, fmtstr); |
|
88 have_gp_cmd = true; |
|
89 endif |
|
90 x = new; |
|
91 y_set = 0; |
|
92 else |
|
93 y = new; |
|
94 y_set = 1; |
|
95 endif |
|
96 else |
|
97 x = new; |
|
98 x_set = 1; |
4
|
99 endif |
934
|
100 |
5116
|
101 endwhile |
|
102 |
|
103 ## Handle last plot. |
934
|
104 |
5116
|
105 if (x_set) |
|
106 if (y_set) |
|
107 [data{j}, fmtstr] = __plt2__ (x, y, fmt); |
|
108 else |
|
109 [data{j}, fmtstr] = __plt1__ (x, fmt); |
4
|
110 endif |
5116
|
111 if (iscell (data{j})) |
|
112 for i = 1:length (data{j}) |
|
113 gp_cmd = sprintf ("%s%s data{%d}{%d} %s", gp_cmd, sep, |
|
114 j, i, fmtstr{i}); |
|
115 sep = ",\\\n"; |
|
116 have_gp_cmd = true; |
|
117 endfor |
|
118 else |
|
119 gp_cmd = sprintf ("%s%s data{%d} %s", gp_cmd, sep, j++, fmtstr); |
|
120 have_gp_cmd = true; |
|
121 endif |
|
122 endif |
934
|
123 |
5116
|
124 if (have_gp_cmd) |
|
125 eval (gp_cmd); |
|
126 endif |
4
|
127 else |
934
|
128 msg = sprintf ("%s (x)\n", caller); |
|
129 msg = sprintf ("%s %s (x, y)\n", msg, caller); |
|
130 msg = sprintf ("%s %s (x2, y1, x2, y2)\n", msg, caller); |
|
131 msg = sprintf ("%s %s (x, y, fmt)", msg, caller); |
|
132 usage (msg); |
4
|
133 endif |
|
134 |
|
135 endfunction |