Mercurial > hg > octave-nkf
annotate scripts/plot/__scatter__.m @ 9665:1dba57e9d08d
use blas_trans_type for xgemm
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 26 Sep 2009 10:41:07 +0200 |
parents | 10b9a71a81f1 |
children |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2007, 2008, 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 | |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8257
diff
changeset
|
19 ## -*- texinfo -*- |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8257
diff
changeset
|
20 ## @deftypefn {Function File} {@var{hg} =} __scatter__ (@dots{}) |
7189 | 21 ## Undocumented internal function. |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8257
diff
changeset
|
22 ## @end deftypefn |
7189 | 23 |
8257 | 24 function hg = __scatter__ (varargin) |
7191 | 25 |
26 h = varargin{1}; | |
27 nd = varargin{2}; | |
28 fcn = varargin{3}; | |
29 x = varargin{4}(:); | |
30 y = varargin{5}(:); | |
7189 | 31 istart = 6; |
7191 | 32 |
7189 | 33 if (nd == 3) |
7191 | 34 z = varargin{6}(:); |
7421 | 35 idx = isnan(x) | isnan (y) | isnan (z); |
36 x (idx) = []; | |
37 y (idx) = []; | |
38 z (idx) = []; | |
7189 | 39 istart = 7; |
40 else | |
7421 | 41 idx = isnan(x) | isnan (y); |
42 x (idx) = []; | |
43 y (idx) = []; | |
7191 | 44 z = zeros (length (x), 0); |
7189 | 45 endif |
46 | |
47 firstnonnumeric = Inf; | |
48 for i = istart:nargin | |
7191 | 49 if (! isnumeric (varargin{i})) |
7189 | 50 firstnonnumeric = i; |
51 break; | |
52 endif | |
53 endfor | |
54 | |
7235 | 55 if (istart < nargin && firstnonnumeric > istart) |
7191 | 56 s = varargin{istart}; |
7189 | 57 if (isempty (s)) |
7603
689652eb95d1
fix for scatter markersize
David Bateman <dbateman@free.fr>
parents:
7421
diff
changeset
|
58 s = 6; |
7189 | 59 endif |
60 else | |
7603
689652eb95d1
fix for scatter markersize
David Bateman <dbateman@free.fr>
parents:
7421
diff
changeset
|
61 s = 6; |
7189 | 62 endif |
8257 | 63 if (numel (s) == 1) |
64 ss = s; | |
65 s = repmat (s, numel(x), 1); | |
66 endif | |
7189 | 67 |
68 if (istart < nargin && firstnonnumeric > istart + 1) | |
7191 | 69 c = varargin{istart + 1}; |
7189 | 70 if (isvector (c)) |
8257 | 71 if (columns (c) == 3) |
72 cc = c; | |
73 c = repmat (c, numel(x), 1); | |
74 else | |
75 c = c(:); | |
76 endif | |
9295
10b9a71a81f1
__scatter__.m: If the color spec is empty, set using __next_line_color__.
Ben Abbott <bpabbott@mac.com>
parents:
9085
diff
changeset
|
77 elseif (isempty (c)) |
10b9a71a81f1
__scatter__.m: If the color spec is empty, set using __next_line_color__.
Ben Abbott <bpabbott@mac.com>
parents:
9085
diff
changeset
|
78 cc = __next_line_color__(); |
10b9a71a81f1
__scatter__.m: If the color spec is empty, set using __next_line_color__.
Ben Abbott <bpabbott@mac.com>
parents:
9085
diff
changeset
|
79 c = repmat (cc, numel(x), 1); |
7189 | 80 endif |
7191 | 81 elseif (firstnonnumeric == istart + 1 && ischar (varargin{istart + 1})) |
7189 | 82 c = varargin{istart + 1}; |
83 firstnonnumeric++; | |
84 else | |
8257 | 85 cc = __next_line_color__(); |
86 c = repmat (cc, numel(x), 1); | |
7189 | 87 endif |
88 | |
89 newargs = {}; | |
90 filled = false; | |
91 have_marker = false; | |
92 marker = "o"; | |
93 iarg = firstnonnumeric; | |
94 while (iarg <= nargin) | |
7191 | 95 arg = varargin{iarg++}; |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7768
diff
changeset
|
96 if (ischar (arg) && strncmpi (arg, "filled", 6)) |
7189 | 97 filled = true; |
7768
a2d9f325b65a
Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents:
7603
diff
changeset
|
98 elseif ((ischar (arg) || iscell (arg)) && ! have_marker) |
8257 | 99 [linespec, valid] = __pltopt__ (fcn, arg, false); |
7189 | 100 if (valid) |
101 have_marker = true; | |
102 marker = linespec.marker; | |
103 if (strncmp (marker, "none", 4)) | |
104 marker = "o"; | |
105 endif | |
106 else | |
8257 | 107 error ("%s: invalid linespec", fcn); |
7189 | 108 endif |
109 else | |
110 newargs{end+1} = arg; | |
111 if (iarg <= nargin) | |
112 newargs{end+1} = varagin{iarg++}; | |
113 endif | |
114 endif | |
115 endwhile | |
116 | |
8257 | 117 hg = hggroup (); |
118 newargs = __add_datasource__ (fcn, hg, {"x", "y", "z", "c", "size"}, | |
119 newargs{:}); | |
120 | |
121 addproperty ("xdata", hg, "data", x); | |
122 addproperty ("ydata", hg, "data", y); | |
123 addproperty ("zdata", hg, "data", z); | |
124 if (exist ("cc", "var")) | |
125 addproperty ("cdata", hg, "data", cc); | |
126 else | |
127 addproperty ("cdata", hg, "data", c); | |
128 endif | |
129 if (exist ("ss", "var")) | |
130 addproperty ("sizedata", hg, "data", ss); | |
7189 | 131 else |
8257 | 132 addproperty ("sizedata", hg, "data", s); |
133 endif | |
134 addlistener (hg, "xdata", @update_data); | |
135 addlistener (hg, "ydata", @update_data); | |
136 addlistener (hg, "zdata", @update_data); | |
137 addlistener (hg, "cdata", @update_data); | |
138 addlistener (hg, "sizedata", @update_data); | |
139 | |
140 if (ischar (c)) | |
141 for i = 1 : numel (x) | |
142 h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), | |
143 "faces", 1, "vertices", [x(i), y(i), z(i,:)], | |
144 "facecolor", "none", "edgecolor", c, "marker", marker, | |
145 "markersize", s(i), "linestyle", "none"); | |
146 if (filled) | |
147 set(h, "markerfacecolor", c); | |
148 endif | |
149 endfor | |
150 else | |
151 for i = 1 : numel (x) | |
152 h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), | |
153 "faces", 1, "vertices", [x(i), y(i), z(i,:)], | |
154 "facecolor", "none", "edgecolor", "flat", | |
9085
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
155 "cdata", reshape(c(i,:),[1,size(c)(2:end)]), |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
156 "marker", marker, "markersize", s(i), |
8257 | 157 "linestyle", "none"); |
158 if (filled) | |
159 set(h, "markerfacecolor", "flat"); | |
160 endif | |
161 endfor | |
162 ax = get (hg, "parent"); | |
7189 | 163 clim = get (ax, "clim"); |
164 if (min(c(:)) < clim(1)) | |
165 clim(1) = min(c(:)); | |
166 set (ax, "clim", clim); | |
167 endif | |
168 if (max(c(:)) > clim(2)) | |
169 set (ax, "clim", [clim(1), max(c(:))]); | |
170 endif | |
171 endif | |
172 | |
8257 | 173 addproperty ("linewidth", hg, "patchlinewidth", 0.5); |
174 addproperty ("marker", hg, "patchmarker", marker); | |
175 if (numel (x) > 0) | |
176 addproperty ("markerfacecolor", hg, "patchmarkerfacecolor", "none"); | |
177 addproperty ("markeredgecolor", hg, "patchmarkeredgecolor", "none"); | |
178 else | |
179 addproperty ("markerfacecolor", hg, "patchmarkerfacecolor", | |
180 get (h, "markerfacecolor")); | |
181 addproperty ("markeredgecolor", hg, "patchmarkeredgecolor", | |
182 get (h, "edgecolor")); | |
183 endif | |
184 addlistener (hg, "linewidth", @update_props); | |
185 addlistener (hg, "marker", @update_props); | |
186 addlistener (hg, "markerfacecolor", @update_props); | |
187 addlistener (hg, "markeredgecolor", @update_props); | |
188 | |
189 if (! isempty (newargs)) | |
190 set (hg, newargs{:}) | |
191 endif | |
192 | |
7189 | 193 endfunction |
8257 | 194 |
195 function update_props (h, d) | |
196 lw = get (h, "linewidth"); | |
197 m = get (h, "marker"); | |
198 fc = get (h, "markerfacecolor"); | |
199 ec = get (h, "markeredgecolor"); | |
200 kids = get (h, "children"); | |
201 | |
202 for i = 1 : numel (kids) | |
203 set (kids (i), "linewidth", lw, "marker", m, "markerfacecolor", fc, | |
204 "edgecolor", ec) | |
205 endfor | |
206 endfunction | |
207 | |
208 function update_data (h, d) | |
209 x1 = get (h, "xdata"); | |
210 y1 = get (h, "ydata"); | |
211 z1 = get (h, "zdata"); | |
212 c1 = get (h, "cdata"); | |
213 if (!ischar (c1) && rows (c1) == 1) | |
214 c1 = repmat (c1, numel (x1), 1); | |
215 endif | |
216 size1 = get (h, "sizedata"); | |
217 if (numel (size1) == 1) | |
218 size1 = repmat (size1, numel (x1), 1); | |
219 endif | |
220 hlist = get (h, "children"); | |
221 if (ischar (c1)) | |
9085
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
222 if (isempty (z1)) |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
223 for i = 1 : length (hlist) |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
224 set (hlist(i), "vertices", [x1(i), y1(i)], "cdata", c1, |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
225 "markersize", size1(i)); |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
226 endfor |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
227 else |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
228 for i = 1 : length (hlist) |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
229 set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata", c1, |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
230 "markersize", size1(i)); |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
231 endfor |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
232 endif |
8257 | 233 else |
9085
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
234 if (isempty (z1)) |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
235 for i = 1 : length (hlist) |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
236 set (hlist(i), "vertices", [x1(i), y1(i)], "cdata", |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
237 reshape(c1(i,:),[1, size(c1)(2:end)]), "markersize", size1(i)); |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
238 endfor |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
239 else |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
240 for i = 1 : length (hlist) |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
241 set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata", |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
242 reshape(c1(i,:),[1, size(c1)(2:end)]), "markersize", size1(i)); |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
243 endfor |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
244 endif |
8257 | 245 endif |
246 endfunction |