Mercurial > hg > octave-lyh
annotate scripts/plot/scatter.m @ 10697:1215ab6f3491
Honor Matlab color settings for scatter().
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Thu, 10 Jun 2010 19:16:56 -0400 |
parents | 16f53d29049f |
children | da51afafca80 |
rev | line source |
---|---|
9245 | 1 ## Copyright (C) 2007, 2009 David Bateman |
7189 | 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} {} scatter (@var{x}, @var{y}, @var{s}, @var{c}) | |
21 ## @deftypefnx {Function File} {} scatter (@dots{}, 'filled') | |
22 ## @deftypefnx {Function File} {} scatter (@dots{}, @var{style}) | |
23 ## @deftypefnx {Function File} {} scatter (@dots{}, @var{prop}, @var{val}) | |
24 ## @deftypefnx {Function File} {} scatter (@var{h}, @dots{}) | |
25 ## @deftypefnx {Function File} {@var{h} =} scatter (@dots{}) | |
26 ## | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
7245
diff
changeset
|
27 ## Plot a scatter plot of the data. A marker is plotted at each point |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
7245
diff
changeset
|
28 ## defined by the points in the vectors @var{x} and @var{y}. The size of |
7189 | 29 ## the markers used is determined by the @var{s}, which can be a scalar, |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
7245
diff
changeset
|
30 ## a vector of the same length of @var{x} and @var{y}. If @var{s} is not |
7189 | 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. | |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
7245
diff
changeset
|
41 ## If the argument 'filled' is given then the markers as filled. All |
7189 | 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 = randn (100, 1); | |
49 ## y = randn (100, 1); | |
50 ## scatter (x, y, [], sqrt(x.^2 + y.^2)); | |
51 ## @end group | |
52 ## @end example | |
53 ## | |
54 ## @seealso{plot, patch, scatter3} | |
55 ## @end deftypefn | |
56 | |
57 function retval = scatter (varargin) | |
58 | |
7215 | 59 [h, varargin, nargin] = __plt_get_axis_arg__ ("scatter", varargin{:}); |
60 | |
7189 | 61 if (nargin < 2) |
62 print_usage (); | |
7215 | 63 else |
7189 | 64 oldh = gca (); |
65 unwind_protect | |
66 axes (h); | |
67 newplot (); | |
7215 | 68 tmp = __scatter__ (h, 2, "scatter", varargin{:}); |
7189 | 69 unwind_protect_cleanup |
70 axes (oldh); | |
71 end_unwind_protect | |
72 endif | |
73 | |
74 if (nargout > 0) | |
75 retval = tmp; | |
76 endif | |
77 | |
78 endfunction | |
7245 | 79 |
80 %!demo | |
81 %! x = randn (100, 1); | |
82 %! y = randn (100, 1); | |
10697
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
83 %! scatter (x, y, "r") |
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
84 |
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
85 %!demo |
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
86 %! x = randn (100, 1); |
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
87 %! y = randn (100, 1); |
7245 | 88 %! scatter (x, y, [], sqrt(x.^2 + y.^2)); |
10697
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
89 |
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
90 %!demo |
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
91 %! x = rand (10, 1); |
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
92 %! y = rand (10, 1); |
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
93 %! s = 10 - 10 * log (x.^2+y.^2); |
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
94 %! h = scatter (x, y, s, s, "s", "filled"); |
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
95 |