7189
|
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 ## Undocumented internal function. |
|
20 |
|
21 function h = __scatter__ (varargin) |
|
22 h = varargin {1}; |
|
23 nd = varargin {2}; |
|
24 fcn = varargin {3}; |
|
25 x = varargin {4}(:); |
|
26 y = varargin {5}(:); |
|
27 istart = 6; |
|
28 if (nd == 3) |
|
29 z = varargin {6}(:); |
|
30 istart = 7; |
|
31 else |
|
32 z = zeros (length(x), 0); |
|
33 endif |
|
34 |
|
35 firstnonnumeric = Inf; |
|
36 for i = istart:nargin |
|
37 if (! isnumeric (varargin {i})) |
|
38 firstnonnumeric = i; |
|
39 break; |
|
40 endif |
|
41 endfor |
|
42 |
|
43 if (firstnonnumeric > istart) |
|
44 s = varargin {istart}; |
|
45 if (isempty (s)) |
|
46 s = 8; |
|
47 endif |
|
48 else |
|
49 s = 8; |
|
50 endif |
|
51 ## Note markersize is in points^2 for 2D and points for 3D, and |
|
52 ## the below is an approximation, that is empircally visually correct. |
|
53 if (nd == 2) |
|
54 s = sqrt (s) / 2; |
|
55 else |
|
56 s = s / 4; |
|
57 endif |
|
58 |
|
59 if (istart < nargin && firstnonnumeric > istart + 1) |
|
60 c = varargin {istart + 1}; |
|
61 if (isvector (c)) |
|
62 c = c(:); |
|
63 endif |
|
64 elseif (firstnonnumeric == istart + 1 && ischar (varargin {istart + 1})) |
|
65 c = varargin{istart + 1}; |
|
66 firstnonnumeric++; |
|
67 else |
|
68 c = 1 : length(x); |
|
69 endif |
|
70 |
|
71 newargs = {}; |
|
72 filled = false; |
|
73 have_marker = false; |
|
74 marker = "o"; |
|
75 iarg = firstnonnumeric; |
|
76 while (iarg <= nargin) |
|
77 arg = varargin {iarg++}; |
|
78 if (ischar (arg) && strncmp (tolower (arg), "filled", 6)) |
|
79 filled = true; |
|
80 elseif ((isstr (arg) || iscell (arg)) && ! have_marker) |
|
81 [linespec, valid] = __pltopt__ ("scatter", arg, false); |
|
82 if (valid) |
|
83 have_marker = true; |
|
84 marker = linespec.marker; |
|
85 if (strncmp (marker, "none", 4)) |
|
86 marker = "o"; |
|
87 endif |
|
88 else |
|
89 error ("scatter: invalid linespec"); |
|
90 endif |
|
91 else |
|
92 newargs{end+1} = arg; |
|
93 if (iarg <= nargin) |
|
94 newargs{end+1} = varagin{iarg++}; |
|
95 endif |
|
96 endif |
|
97 endwhile |
|
98 |
|
99 if (ischar (c)) |
|
100 h = patch('faces', [1:length(x)].', 'vertices', [x, y, z], 'facecolor', |
|
101 'none', 'edgecolor', c, 'marker', marker, |
|
102 'markersize', s, 'linestyle', 'none'); |
|
103 if (filled) |
|
104 set(h, 'markerfacecolor', c); |
|
105 endif |
|
106 else |
|
107 h = patch('faces', [1:length(x)].', 'vertices', [x, y, z], 'facecolor', |
|
108 'none', 'edgecolor', 'flat', 'cdata', c, 'marker', marker, |
|
109 'markersize', s, 'linestyle', 'none'); |
|
110 if (filled) |
|
111 set(h, 'markerfacecolor', 'flat'); |
|
112 endif |
|
113 ax = get (h, "parent"); |
|
114 clim = get (ax, "clim"); |
|
115 if (min(c(:)) < clim(1)) |
|
116 clim(1) = min(c(:)); |
|
117 set (ax, "clim", clim); |
|
118 endif |
|
119 if (max(c(:)) > clim(2)) |
|
120 set (ax, "clim", [clim(1), max(c(:))]); |
|
121 endif |
|
122 endif |
|
123 |
|
124 endfunction |