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