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 |
3979
|
26 function __plt__ (caller, varargin) |
934
|
27 |
4717
|
28 nargs = nargin (); |
|
29 |
5119
|
30 if (nargs > 1) |
934
|
31 |
5116
|
32 k = 1; |
|
33 j = 1; |
5119
|
34 |
|
35 x_set = false; |
|
36 y_set = false; |
|
37 have_gp_cmd = false; |
|
38 |
5215
|
39 gp_cmd = "__gnuplot_plot__"; |
5117
|
40 sep = ""; |
934
|
41 |
5116
|
42 ## Gather arguments, decode format, gather plot strings, and plot lines. |
934
|
43 |
5119
|
44 while (--nargs > 0 || x_set) |
5115
|
45 |
5119
|
46 if (nargs == 0) |
|
47 ## Force the last plot when input variables run out. |
|
48 next_arg = ""; |
5118
|
49 else |
5119
|
50 next_arg = varargin{k++}; |
5116
|
51 endif |
934
|
52 |
5119
|
53 have_data = false; |
5118
|
54 |
5119
|
55 if (isstr (next_arg)) |
|
56 if (x_set) |
|
57 fmt = __pltopt__ (caller, next_arg); |
|
58 if (y_set) |
|
59 [data{j}, fmtstr] = __plt2__ (x, y, fmt); |
|
60 else |
|
61 [data{j}, fmtstr] = __plt1__ (x, fmt); |
|
62 endif |
|
63 have_data = true; |
|
64 x_set = false; |
|
65 y_set = false; |
|
66 else |
5116
|
67 error ("plot: no data to plot"); |
|
68 endif |
|
69 elseif (x_set) |
|
70 if (y_set) |
5395
|
71 fmt = __pltopt__ (caller, ""); |
|
72 [data{j}, fmtstr] = __plt2__ (x, y, fmt); |
5119
|
73 have_data = true; |
|
74 x = next_arg; |
|
75 y_set = false; |
5116
|
76 else |
5119
|
77 y = next_arg; |
|
78 y_set = true; |
5116
|
79 endif |
|
80 else |
5119
|
81 x = next_arg; |
|
82 x_set = true; |
4
|
83 endif |
934
|
84 |
5119
|
85 if (have_data) |
5118
|
86 if (iscell (data{j})) |
|
87 for i = 1:length (data{j}) |
|
88 gp_cmd = sprintf ("%s%s data{%d}{%d} %s", gp_cmd, sep, |
|
89 j, i, fmtstr{i}); |
|
90 sep = ",\\\n"; |
|
91 endfor |
|
92 else |
5119
|
93 gp_cmd = sprintf ("%s%s data{%d} %s", gp_cmd, sep, j, fmtstr); |
5116
|
94 sep = ",\\\n"; |
5118
|
95 endif |
5119
|
96 j++; |
5116
|
97 have_gp_cmd = true; |
|
98 endif |
5118
|
99 |
|
100 endwhile |
934
|
101 |
5116
|
102 if (have_gp_cmd) |
|
103 eval (gp_cmd); |
|
104 endif |
5118
|
105 |
4
|
106 else |
5119
|
107 msg = sprintf ("%s (y)\n", caller); |
|
108 msg = sprintf ("%s %s (x, y, ...)\n", msg, caller); |
|
109 msg = sprintf ("%s %s (x, y, fmt, ...)", msg, caller); |
934
|
110 usage (msg); |
4
|
111 endif |
|
112 |
|
113 endfunction |