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