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 |
|
28 if (nargin == 2) |
|
29 |
3979
|
30 __plt1__ (varargin{1}, ""); |
934
|
31 |
|
32 elseif (nargin > 2) |
|
33 |
|
34 first_plot = 1; |
2523
|
35 hold_state = ishold (); |
4
|
36 |
934
|
37 unwind_protect |
|
38 |
3979
|
39 k = 1; |
|
40 x = varargin{k++}; |
934
|
41 nargin = nargin - 2; |
|
42 x_set = 1; |
|
43 y_set = 0; |
|
44 |
2303
|
45 ## Gather arguments, decode format, and plot lines. |
934
|
46 |
|
47 while (nargin-- > 0) |
|
48 |
3426
|
49 fmt = ""; |
3979
|
50 new = varargin{k++}; |
4
|
51 |
3426
|
52 if (isstr (new)) |
|
53 if (! x_set) |
|
54 error ("plot: no data to plot"); |
|
55 endif |
|
56 fmt = __pltopt__ (caller, new); |
|
57 if (! y_set) |
|
58 __plt1__ (x, fmt); |
|
59 else |
|
60 __plt2__ (x, y, fmt); |
|
61 endif |
|
62 hold on; |
|
63 x_set = 0; |
|
64 y_set = 0; |
|
65 elseif (x_set) |
|
66 if (y_set) |
|
67 __plt2__ (x, y, fmt); |
|
68 hold on; |
|
69 x = new; |
|
70 y_set = 0; |
|
71 else |
|
72 y = new; |
|
73 y_set = 1; |
|
74 endif |
|
75 else |
|
76 x = new; |
|
77 x_set = 1; |
|
78 endif |
934
|
79 |
|
80 endwhile |
|
81 |
2303
|
82 ## Handle last plot. |
934
|
83 |
|
84 if (x_set) |
3426
|
85 if (y_set) |
|
86 __plt2__ (x, y, fmt); |
|
87 else |
|
88 __plt1__ (x, fmt); |
|
89 endif |
4
|
90 endif |
934
|
91 |
|
92 unwind_protect_cleanup |
|
93 |
|
94 if (! hold_state) |
1518
|
95 hold off; |
4
|
96 endif |
934
|
97 |
|
98 end_unwind_protect |
|
99 |
4
|
100 else |
934
|
101 |
|
102 msg = sprintf ("%s (x)\n", caller); |
|
103 msg = sprintf ("%s %s (x, y)\n", msg, caller); |
|
104 msg = sprintf ("%s %s (x2, y1, x2, y2)\n", msg, caller); |
|
105 msg = sprintf ("%s %s (x, y, fmt)", msg, caller); |
|
106 usage (msg); |
|
107 |
4
|
108 endif |
|
109 |
|
110 endfunction |