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