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