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; |
5118
|
34 nargs -= 1; |
|
35 x_set = 0; |
5116
|
36 y_set = 0; |
|
37 gp_cmd = "gplot"; |
|
38 have_gp_cmd = false; |
5117
|
39 sep = ""; |
934
|
40 |
5116
|
41 ## Gather arguments, decode format, gather plot strings, and plot lines. |
934
|
42 |
5118
|
43 while ((nargs-- > 0) || x_set) |
5115
|
44 |
5118
|
45 if (k < nargin()) |
|
46 new = varargin{k++}; |
|
47 else |
|
48 new = ""; ## Force the last plot when input variables run out. |
5116
|
49 endif |
934
|
50 |
5118
|
51 queue_plot = false; |
|
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 |
5118
|
63 queue_plot = true; |
5116
|
64 x_set = 0; |
|
65 y_set = 0; |
|
66 elseif (x_set) |
|
67 if (y_set) |
5118
|
68 [data{j}, fmtstr] = __plt2__ (x, y, ""); |
|
69 queue_plot = true; |
5116
|
70 x = new; |
|
71 y_set = 0; |
|
72 else |
|
73 y = new; |
|
74 y_set = 1; |
|
75 endif |
|
76 else |
|
77 x = new; |
|
78 x_set = 1; |
4
|
79 endif |
934
|
80 |
5118
|
81 if (queue_plot) |
|
82 if (iscell (data{j})) |
|
83 for i = 1:length (data{j}) |
|
84 gp_cmd = sprintf ("%s%s data{%d}{%d} %s", gp_cmd, sep, |
|
85 j, i, fmtstr{i}); |
|
86 sep = ",\\\n"; |
|
87 endfor |
|
88 j++; |
|
89 else |
|
90 gp_cmd = sprintf ("%s%s data{%d} %s", gp_cmd, sep, j++, fmtstr); |
5116
|
91 sep = ",\\\n"; |
5118
|
92 endif |
5116
|
93 have_gp_cmd = true; |
|
94 endif |
5118
|
95 |
|
96 endwhile |
934
|
97 |
5116
|
98 if (have_gp_cmd) |
|
99 eval (gp_cmd); |
|
100 endif |
5118
|
101 |
4
|
102 else |
934
|
103 msg = sprintf ("%s (x)\n", caller); |
|
104 msg = sprintf ("%s %s (x, y)\n", msg, caller); |
|
105 msg = sprintf ("%s %s (x2, y1, x2, y2)\n", msg, caller); |
|
106 msg = sprintf ("%s %s (x, y, fmt)", msg, caller); |
|
107 usage (msg); |
4
|
108 endif |
|
109 |
|
110 endfunction |