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