1014
|
1 # Copyright (C) 1993, 1994, 1995 John W. Eaton |
245
|
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 the |
|
7 # Free Software Foundation; either version 2, or (at your option) any |
|
8 # later version. |
|
9 # |
|
10 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 # 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 |
1315
|
17 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
245
|
18 |
934
|
19 function plot_int (caller, ...) |
|
20 |
|
21 if (nargin == 2) |
|
22 |
|
23 plot_int_1 (va_arg (), ""); |
|
24 |
|
25 elseif (nargin > 2) |
|
26 |
|
27 first_plot = 1; |
|
28 hold_state = ishold; |
4
|
29 |
934
|
30 unwind_protect |
|
31 |
|
32 x = va_arg (); |
|
33 nargin = nargin - 2; |
|
34 x_set = 1; |
|
35 y_set = 0; |
|
36 |
|
37 # Gather arguments, decode format, and plot lines. |
|
38 |
|
39 while (nargin-- > 0) |
|
40 |
|
41 fmt = ""; |
|
42 new = va_arg (); |
4
|
43 |
934
|
44 if (isstr (new)) |
|
45 if (! x_set) |
|
46 error ("plot: no data to plot"); |
|
47 endif |
|
48 fmt = plot_opt (caller, new); |
|
49 if (! y_set) |
1518
|
50 plot_int_1 (x, fmt); |
934
|
51 else |
1518
|
52 plot_int_2 (x, y, fmt); |
934
|
53 endif |
1518
|
54 hold on; |
934
|
55 x_set = 0; |
|
56 y_set = 0; |
|
57 elseif (x_set) |
|
58 if (y_set) |
|
59 plot_int_2 (x, y, fmt); |
1518
|
60 hold on; |
934
|
61 x = new; |
|
62 y_set = 0; |
|
63 else |
|
64 y = new; |
|
65 y_set = 1; |
|
66 endif |
|
67 else |
|
68 x = new; |
|
69 x_set = 1; |
|
70 endif |
|
71 |
|
72 endwhile |
|
73 |
|
74 # Handle last plot. |
|
75 |
|
76 if (x_set) |
|
77 if (y_set) |
|
78 plot_int_2 (x, y, fmt); |
|
79 else |
|
80 plot_int_1 (x, fmt); |
|
81 endif |
4
|
82 endif |
934
|
83 |
|
84 unwind_protect_cleanup |
|
85 |
|
86 if (! hold_state) |
1518
|
87 hold off; |
4
|
88 endif |
934
|
89 |
|
90 end_unwind_protect |
|
91 |
4
|
92 else |
934
|
93 |
|
94 msg = sprintf ("%s (x)\n", caller); |
|
95 msg = sprintf ("%s %s (x, y)\n", msg, caller); |
|
96 msg = sprintf ("%s %s (x2, y1, x2, y2)\n", msg, caller); |
|
97 msg = sprintf ("%s %s (x, y, fmt)", msg, caller); |
|
98 usage (msg); |
|
99 |
4
|
100 endif |
|
101 |
|
102 endfunction |