comparison scripts/plot/scatter3.m @ 7189:e8d953d03f6a

[project @ 2007-11-26 20:42:09 by dbateman]
author dbateman
date Mon, 26 Nov 2007 20:42:11 +0000
parents
children a730e47fda4d
comparison
equal deleted inserted replaced
7188:fdd7cd70dc14 7189:e8d953d03f6a
1 ## Copyright (C) 2007 David Bateman
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 3 of the License, or (at
8 ## your option) 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, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} scatter3 (@var{x}, @var{y}, @var{s}, @var{c})
21 ## @deftypefnx {Function File} {} scatter3 (@dots{}, 'filled')
22 ## @deftypefnx {Function File} {} scatter3 (@dots{}, @var{style})
23 ## @deftypefnx {Function File} {} scatter3 (@dots{}, @var{prop}, @var{val})
24 ## @deftypefnx {Function File} {} scatter3 (@var{h}, @dots{})
25 ## @deftypefnx {Function File} {@var{h} =} scatter3 (@dots{})
26 ##
27 ## Plot a scatter plot of the data in 3D. A marker is ploted at each point
28 ## defined by the points in the vectors @var{x} and @var{y}. The size of
29 ## the markers used is determined by the @var{s}, which can be a scalar,
30 ## a vector of the same length of @var{x} and @var{y}. If @var{s} is not
31 ## given or is an empty matrix, then the default value of 8 points is used.
32 ##
33 ## The color of the markers is determined by @var{c}, which can be a string
34 ## defining a fixed color, a 3 element vector giving the red, green and blue
35 ## components of the color, a vector of the same length as @var{x} that gives
36 ## a scaled index into the current colormap, or a @var{n}-by-3 matrix defining
37 ## the colors of each of the markers individually.
38 ##
39 ## The marker to use can be changed with the @var{style} argument, that is a
40 ## string defining a marker in the same manner as the @code{plot} command.
41 ## If the argument 'filled' is given then the markers as filled. All
42 ## additional arguments are passed to the underlying patch command.
43 ##
44 ## The optional return value @var{h} provides a handle to the patch object
45 ##
46 ## @example
47 ## @group
48 ## [x, y, z] = peaks (20);
49 ## scatter3 (x(:), y(:), z(:), [], z(:));
50 ## @end group
51 ## @end example
52 ##
53 ## @seealso{plot, patch, scatter}
54 ## @end deftypefn
55
56 function retval = scatter3 (varargin)
57
58 if (nargin < 2)
59 print_usage ();
60 elseif (isscalar (varargin{1}) && ishandle (varargin{1}))
61 h = varargin {1};
62 if (! strcmp (get (h, "type"), "axes"))
63 error ("scatter3: expecting first argument to be an axes object");
64 endif
65 oldh = gca ();
66 unwind_protect
67 axes (h);
68 newplot ();
69 tmp = __scatter__ (h, 3, "scatter3", varargin{2:end});
70 unwind_protect_cleanup
71 axes (oldh);
72 end_unwind_protect
73 else
74 newplot ();
75 tmp = __scatter__ (gca (), 3, "scatter3", varargin{:});
76 endif
77
78 if (! ishold ())
79 set (get (tmp, "parent"), "view", [-37.5, 30]);
80 endif
81
82 if (nargout > 0)
83 retval = tmp;
84 endif
85
86 endfunction