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) |
5741
|
59 [tdata, tfmtstr] = __plt2__ (x, y, fmt); |
5119
|
60 else |
5741
|
61 [tdata, tfmtstr] = __plt1__ (x, fmt); |
5119
|
62 endif |
5741
|
63 if (! isempty (tdata)) |
|
64 __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j} = tdata; |
|
65 fmtstr = tfmtstr; |
|
66 have_data = true; |
|
67 endif |
5119
|
68 x_set = false; |
|
69 y_set = false; |
|
70 else |
5116
|
71 error ("plot: no data to plot"); |
|
72 endif |
|
73 elseif (x_set) |
|
74 if (y_set) |
5395
|
75 fmt = __pltopt__ (caller, ""); |
5741
|
76 [tdata, tfmtstr] = __plt2__ (x, y, fmt); |
|
77 if (! isempty (tdata)) |
|
78 __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j} = tdata; |
|
79 fmtstr = tfmtstr; |
|
80 have_data = true; |
|
81 endif |
5119
|
82 x = next_arg; |
|
83 y_set = false; |
5116
|
84 else |
5119
|
85 y = next_arg; |
|
86 y_set = true; |
5116
|
87 endif |
|
88 else |
5119
|
89 x = next_arg; |
|
90 x_set = true; |
4
|
91 endif |
934
|
92 |
5119
|
93 if (have_data) |
5493
|
94 if (iscell (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j})) |
|
95 for i = 1:length (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}) |
5958
|
96 usingstr = make_using_clause (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}{i}); |
5493
|
97 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} \ |
5958
|
98 = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d}{%d} %s %s", |
5493
|
99 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}, |
5958
|
100 __plot_command_sep__, j, i, usingstr, fmtstr{i}); |
5406
|
101 __plot_command_sep__ = ",\\\n"; |
5118
|
102 endfor |
|
103 else |
5958
|
104 usingstr = make_using_clause (__plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{j}); |
5493
|
105 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__} \ |
5958
|
106 = sprintf ("%s%s __plot_data__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}{%d} %s %s", |
5493
|
107 __plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}, |
5958
|
108 __plot_command_sep__, j, usingstr, fmtstr); |
5406
|
109 __plot_command_sep__ = ",\\\n"; |
5118
|
110 endif |
5119
|
111 j++; |
5116
|
112 endif |
5118
|
113 |
|
114 endwhile |
934
|
115 |
5493
|
116 __plot_data_offset__{__current_figure__}(__multiplot_xi__,__multiplot_yi__) = j; |
5406
|
117 |
5741
|
118 if (__multiplot_mode__) |
|
119 __gnuplot_raw__ ("clear\n"); |
|
120 endif |
|
121 if (! strcmp (__plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}, "__gnuplot_plot__")) |
5493
|
122 eval (__plot_command__{__current_figure__}{__multiplot_xi__,__multiplot_yi__}); |
5116
|
123 endif |
5118
|
124 |
4
|
125 else |
5119
|
126 msg = sprintf ("%s (y)\n", caller); |
|
127 msg = sprintf ("%s %s (x, y, ...)\n", msg, caller); |
|
128 msg = sprintf ("%s %s (x, y, fmt, ...)", msg, caller); |
934
|
129 usage (msg); |
4
|
130 endif |
|
131 |
5958
|
132 ## endfunction |
|
133 |
|
134 function usingstr = make_using_clause (x) |
|
135 cols = columns (x); |
|
136 if (cols > 0) |
|
137 usingstr = strcat (gnuplot_command_using, " ($1)"); |
|
138 for k = 2:cols |
|
139 usingstr = sprintf ("%s:($%d)", usingstr, k); |
|
140 endfor |
|
141 else |
|
142 usingstr = ""; |
|
143 endif |
|
144 ## endfunction |