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 |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, 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 |
5406
|
28 __plot_globals__; |
|
29 |
5493
|
30 __setup_plot__; |
|
31 |
4717
|
32 nargs = nargin (); |
|
33 |
5119
|
34 if (nargs > 1) |
934
|
35 |
5116
|
36 k = 1; |
5493
|
37 j = __plot_data_offset__{__current_figure__}(__multiplot_xi__,__multiplot_yi__); |
5119
|
38 |
|
39 x_set = false; |
|
40 y_set = false; |
934
|
41 |
5116
|
42 ## Gather arguments, decode format, gather plot strings, and plot lines. |
934
|
43 |
5119
|
44 while (--nargs > 0 || x_set) |
5115
|
45 |
5119
|
46 if (nargs == 0) |
|
47 ## Force the last plot when input variables run out. |
|
48 next_arg = ""; |
5118
|
49 else |
5119
|
50 next_arg = varargin{k++}; |
5116
|
51 endif |
934
|
52 |
5119
|
53 have_data = false; |
5118
|
54 |
5443
|
55 if (ischar (next_arg)) |
5119
|
56 if (x_set) |
|
57 fmt = __pltopt__ (caller, next_arg); |
|
58 if (y_set) |
5493
|
59 [__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}, fmtstr] = __plt2__ (x, y, fmt); |
5119
|
60 else |
5493
|
61 [__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}, fmtstr] = __plt1__ (x, fmt); |
5119
|
62 endif |
|
63 have_data = true; |
|
64 x_set = false; |
|
65 y_set = false; |
|
66 else |
5116
|
67 error ("plot: no data to plot"); |
|
68 endif |
|
69 elseif (x_set) |
|
70 if (y_set) |
5395
|
71 fmt = __pltopt__ (caller, ""); |
5493
|
72 [__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}, fmtstr] = __plt2__ (x, y, fmt); |
5119
|
73 have_data = true; |
|
74 x = next_arg; |
|
75 y_set = false; |
5116
|
76 else |
5119
|
77 y = next_arg; |
|
78 y_set = true; |
5116
|
79 endif |
|
80 else |
5119
|
81 x = next_arg; |
|
82 x_set = true; |
4
|
83 endif |
934
|
84 |
5119
|
85 if (have_data) |
5493
|
86 if (iscell (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j})) |
|
87 for i = 1:length (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}) |
|
88 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} \ |
|
89 = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d}{%d} %s", |
|
90 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}, |
5406
|
91 __plot_command_sep__, j, i, fmtstr{i}); |
|
92 __plot_command_sep__ = ",\\\n"; |
5118
|
93 endfor |
|
94 else |
5493
|
95 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} \ |
|
96 = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d} %s", |
|
97 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}, |
5406
|
98 __plot_command_sep__, j, fmtstr); |
|
99 __plot_command_sep__ = ",\\\n"; |
5118
|
100 endif |
5119
|
101 j++; |
5116
|
102 endif |
5118
|
103 |
|
104 endwhile |
934
|
105 |
5493
|
106 __plot_data_offset__{__current_figure__}(__multiplot_xi__,__multiplot_yi__) = j; |
5406
|
107 |
5493
|
108 if (! isempty (__plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__})) |
|
109 if (__multiplot_mode__) |
|
110 __gnuplot_raw__ ("clear\n"); |
|
111 endif |
|
112 eval (__plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}); |
5116
|
113 endif |
5118
|
114 |
4
|
115 else |
5119
|
116 msg = sprintf ("%s (y)\n", caller); |
|
117 msg = sprintf ("%s %s (x, y, ...)\n", msg, caller); |
|
118 msg = sprintf ("%s %s (x, y, fmt, ...)", msg, caller); |
934
|
119 usage (msg); |
4
|
120 endif |
|
121 |
|
122 endfunction |