comparison scripts/plot/plot3.m @ 5910:101d966c8d6b

[project @ 2006-07-28 03:40:22 by jwe]
author jwe
date Fri, 28 Jul 2006 03:40:22 +0000
parents 376e02b2ce70
children 01556febbaaf
comparison
equal deleted inserted replaced
5909:a6a2423a9c25 5910:101d966c8d6b
16 ## along with Octave; see the file COPYING. If not, write to the Free 16 ## along with Octave; see the file COPYING. If not, write to the Free
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 ## 02110-1301, USA. 18 ## 02110-1301, USA.
19 19
20 ## -*- texinfo -*- 20 ## -*- texinfo -*-
21 ## @deftypefn {Function File} {} plot (@var{args}) 21 ## @deftypefn {Function File} {} plot3 (@var{args})
22 ## 22 ##
23 ## This function produces three-dimensional plots. Many different 23 ## This function produces three-dimensional plots. Many different
24 ## combinations of arguments are possible. The simplest form is 24 ## combinations of arguments are possible. The simplest form is
25 ## 25 ##
26 ## @example 26 ## @example
33 ## length, then a single continuous line is drawn. If all arguments are 33 ## length, then a single continuous line is drawn. If all arguments are
34 ## matrices, then each column of the matrices is treated as a seperate 34 ## matrices, then each column of the matrices is treated as a seperate
35 ## line. No attempt is made to transpose the arguments to make the 35 ## line. No attempt is made to transpose the arguments to make the
36 ## number of rows match. 36 ## number of rows match.
37 ## 37 ##
38 ## Additionally, only two arguments can be given as
39 ##
40 ## @example
41 ## plot3 (@var{x}, @var{c})
42 ## @end example
43 ##
44 ## where the real and imaginary parts of the second argument are used as
45 ## the @var{y} and @var{z} coordinates, respectively.
46 ##
47 ## If only one argument is given, as
48 ##
49 ## @example
50 ## plot3 (@var{c})
51 ## @end example
52 ##
53 ## the real and imaginary parts of the argument are used as the @var{y}
54 ## and @var{z} values, and they are plotted versus their index.
55 ##
38 ## To save a plot, in one of several image formats such as PostScript 56 ## To save a plot, in one of several image formats such as PostScript
39 ## or PNG, use the @code{print} command. 57 ## or PNG, use the @code{print} command.
40 ## 58 ##
41 ## An optional format argument can be given as 59 ## An optional format argument can be given as
42 ## 60 ##
116 ## @example 134 ## @example
117 ## plot3 (@var{x1}, @var{y1}, @var{y1}, @var{x2}, @var{y2}, @var{y2}, @dots{}) 135 ## plot3 (@var{x1}, @var{y1}, @var{y1}, @var{x2}, @var{y2}, @var{y2}, @dots{})
118 ## @end example 136 ## @end example
119 ## 137 ##
120 ## @noindent 138 ## @noindent
121 ## where each set of three arguments are treated as seperate lines or 139 ## where each set of three arguments is treated as a seperate line or
122 ## sets of lines in three dimensions. 140 ## set of lines in three dimensions.
141 ##
142 ## To plot multiple one- or two-argument groups, separate each group with an
143 ## empty format string, as
144 ##
145 ## @example
146 ## plot3 (@var{x1}, @var{c1}, '', @var{c2}, '', @dots{})
147 ## @end example
123 ## 148 ##
124 ## An example of the use of plot3 is 149 ## An example of the use of plot3 is
125 ## 150 ##
126 ## @example 151 ## @example
127 ## @group 152 ## @group
128 ## z = [0:0.05:5]; 153 ## z = [0:0.05:5];
129 ## plot3(cos(2*pi*z), sin(2*pi*z), z, ";helix;"); 154 ## plot3(cos(2*pi*z), sin(2*pi*z), z, ";helix;");
155 ## plot3(z, exp(2i*pi*z), ";complex sinusoid;");
130 ## @end group 156 ## @end group
131 ## @end example 157 ## @end example
132 ## 158 ##
133 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__ 159 ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour, __pltopt__
134 ## bar, stairs, errorbar, replot, xlabel, ylabel, title, print} 160 ## bar, stairs, errorbar, replot, xlabel, ylabel, title, print}
151 for arg = 1:nargin 177 for arg = 1:nargin
152 new = varargin{arg}; 178 new = varargin{arg};
153 179
154 if (ischar (new)) 180 if (ischar (new))
155 if (! z_set) 181 if (! z_set)
156 error ("plot3: needs x, y, z"); 182 if (! y_set)
183 if (! x_set)
184 error ("plot3: needs x, [ y, [ z ] ]");
185 else
186 z = imag (x);
187 y = real (x);
188 y_set = 1;
189 z_set = 1;
190 if (rows(x) > 1)
191 x = repmat ((1:rows(x))', 1, columns(x));
192 else
193 x = 1:columns(x);
194 endif
195 endif
196 else
197 z = imag (y);
198 y = real (y);
199 z_set = 1;
200 endif
157 endif 201 endif
158 fmt = __pltopt__ ("plot3", new); 202 fmt = __pltopt__ ("plot3", new);
159 __plt3__(x, y, z, fmt); 203 __plt3__ (x, y, z, fmt);
160 hold on; 204 hold ("on");
161 x_set = 0; 205 x_set = 0;
162 y_set = 0; 206 y_set = 0;
163 z_set = 0; 207 z_set = 0;
164 elseif (! x_set) 208 elseif (! x_set)
165 x = new; 209 x = new;
170 elseif (! z_set) 214 elseif (! z_set)
171 z = new; 215 z = new;
172 z_set = 1; 216 z_set = 1;
173 else 217 else
174 __plt3__ (x, y, z, ""); 218 __plt3__ (x, y, z, "");
175 hold on; 219 hold ("on");
176 x = new; 220 x = new;
177 y_set = 0; 221 y_set = 0;
178 z_set = 0; 222 z_set = 0;
179 endif 223 endif
180 224
181 endfor 225 endfor
182 226
183 ## Handle last plot. 227 ## Handle last plot.
184 228
185 if (z_set) 229 if (x_set)
230 if (y_set)
231 if (! z_set)
232 z = imag (y);
233 y = real (y);
234 z_set = 1;
235 endif
236 else
237 z = imag (x);
238 y = real (x);
239 y_set = 1;
240 z_set = 1;
241 if (rows (x) > 1)
242 x = repmat ((1:rows (x))', 1, columns(x));
243 else
244 x = 1:columns(x);
245 endif
246 endif
186 __plt3__ (x, y, z, ""); 247 __plt3__ (x, y, z, "");
187 elseif (x_set)
188 error ("plot3: needs x, y, z");
189 endif 248 endif
190 249
191 unwind_protect_cleanup 250 unwind_protect_cleanup
192 251
193 if (! hold_state) 252 if (! hold_state)
194 hold off; 253 hold ("off");
195 endif 254 endif
196 255
197 end_unwind_protect 256 end_unwind_protect
198 257
199 endfunction 258 endfunction