comparison scripts/plot/plot3.m @ 6004:01556febbaaf

[project @ 2006-09-26 21:16:52 by jwe]
author jwe
date Tue, 26 Sep 2006 21:16:52 +0000
parents 101d966c8d6b
children 34b1758d3247
comparison
equal deleted inserted replaced
6003:7f8e4f5e2eb7 6004:01556febbaaf
198 y = real (y); 198 y = real (y);
199 z_set = 1; 199 z_set = 1;
200 endif 200 endif
201 endif 201 endif
202 fmt = __pltopt__ ("plot3", new); 202 fmt = __pltopt__ ("plot3", new);
203 __plt3__ (x, y, z, fmt); 203
204 if (isvector (x) && isvector (y))
205 if (isvector (z))
206 x = x(:);
207 y = y(:);
208 z = z(:);
209 elseif (length (x) == rows (z) && length (y) == columns (z))
210 error ("plot3: [length(x), length(y)] must match size(z)");
211 else
212 [x, y] = meshgrid (x, y);
213 endif
214 endif
215
216 if (any (size (x) != size (y)) || any (size (x) != size (z)))
217 error ("plot3: x, y, and z must have the same shape");
218 endif
219
220 unwind_protect
221 __gnuplot_raw__ ("set nohidden3d;\n")
222 __gnuplot_set__ parametric;
223
224 __plt3__ ([([x; NaN*ones(1,size(x,2))])(:), ...
225 ([y; NaN*ones(1,size(y,2))])(:), ...
226 ([z; NaN*ones(1,size(z,2))])(:)], "", fmt);
227
228 unwind_protect_cleanup
229 __gnuplot_set__ noparametric;
230 end_unwind_protect
231
204 hold ("on"); 232 hold ("on");
205 x_set = 0; 233 x_set = 0;
206 y_set = 0; 234 y_set = 0;
207 z_set = 0; 235 z_set = 0;
208 elseif (! x_set) 236 elseif (! x_set)
213 y_set = 1; 241 y_set = 1;
214 elseif (! z_set) 242 elseif (! z_set)
215 z = new; 243 z = new;
216 z_set = 1; 244 z_set = 1;
217 else 245 else
218 __plt3__ (x, y, z, ""); 246 if (isvector (x) && isvector (y))
247 if (isvector (z))
248 x = x(:);
249 y = y(:);
250 z = z(:);
251 elseif (length (x) == rows (z) && length (y) == columns (z))
252 error ("plot3: [length(x), length(y)] must match size(z)");
253 else
254 [x, y] = meshgrid (x, y);
255 endif
256 endif
257
258 if (any (size (x) != size (y)) || any (size (x) != size (z)))
259 error ("plot3: x, y, and z must have the same shape");
260 endif
261
262 unwind_protect
263 __gnuplot_raw__ ("set nohidden3d;\n")
264 __gnuplot_set__ parametric;
265
266 __plt3__ ([([x; NaN*ones(1,size(x,2))])(:), ...
267 ([y; NaN*ones(1,size(y,2))])(:), ...
268 ([z; NaN*ones(1,size(z,2))])(:)]);
269
270 unwind_protect_cleanup
271 __gnuplot_set__ noparametric;
272 end_unwind_protect
273
219 hold ("on"); 274 hold ("on");
220 x = new; 275 x = new;
221 y_set = 0; 276 y_set = 0;
222 z_set = 0; 277 z_set = 0;
223 endif 278 endif
242 x = repmat ((1:rows (x))', 1, columns(x)); 297 x = repmat ((1:rows (x))', 1, columns(x));
243 else 298 else
244 x = 1:columns(x); 299 x = 1:columns(x);
245 endif 300 endif
246 endif 301 endif
247 __plt3__ (x, y, z, ""); 302
303 if (isvector (x) && isvector (y))
304 if (isvector (z))
305 x = x(:);
306 y = y(:);
307 z = z(:);
308 elseif (length (x) == rows (z) && length (y) == columns (z))
309 error ("plot3: [length(x), length(y)] must match size(z)");
310 else
311 [x, y] = meshgrid (x, y);
312 endif
313 endif
314
315 if (any (size (x) != size (y)) || any (size (x) != size (z)))
316 error ("plot3: x, y, and z must have the same shape");
317 endif
318
319 unwind_protect
320 __gnuplot_raw__ ("set nohidden3d;\n")
321 __gnuplot_set__ parametric;
322
323 __plt3__ ([([x; NaN*ones(1,size(x,2))])(:), ...
324 ([y; NaN*ones(1,size(y,2))])(:), ...
325 ([z; NaN*ones(1,size(z,2))])(:)]);
326 unwind_protect_cleanup
327 __gnuplot_set__ noparametric;
328 end_unwind_protect
248 endif 329 endif
249 330
250 unwind_protect_cleanup 331 unwind_protect_cleanup
251 332
252 if (! hold_state) 333 if (! hold_state)