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