Mercurial > octave-nkf
annotate scripts/plot/private/__scatter__.m @ 13986:6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
* __scatter__m (__scatter__): Use simpler logic with built-in unique
function instead of using unique_idx. (render_size_color): Ditto.
(unique_idx): Erase this function.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Sat, 03 Dec 2011 21:57:49 -0500 |
parents | e81ddf9cacd5 |
children | 7ab497513c1a |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2007-2011 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 | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
55 if (istart <= nargin) |
7191 | 56 s = varargin{istart}; |
10697
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
57 if (isempty (s) || ischar (s)) |
7603
689652eb95d1
fix for scatter markersize
David Bateman <dbateman@free.fr>
parents:
7421
diff
changeset
|
58 s = 6; |
10701
657e63dcfd88
scatter.m: Properly set default value markersize and marker type.
Ben Abbott <bpabbott@mac.com>
parents:
10697
diff
changeset
|
59 endif |
657e63dcfd88
scatter.m: Properly set default value markersize and marker type.
Ben Abbott <bpabbott@mac.com>
parents:
10697
diff
changeset
|
60 if (! ischar (varargin{istart})) |
10697
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
61 istart++; |
7189 | 62 endif |
63 else | |
7603
689652eb95d1
fix for scatter markersize
David Bateman <dbateman@free.fr>
parents:
7421
diff
changeset
|
64 s = 6; |
7189 | 65 endif |
66 | |
10697
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
67 if (istart <= nargin && firstnonnumeric > istart) |
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
68 c = varargin{istart}; |
7189 | 69 if (isvector (c)) |
10078 | 70 if (columns (c) != 3) |
10549 | 71 c = c(:); |
8257 | 72 endif |
7189 | 73 endif |
12124
cd82f5933c73
scatter: don't recognize 'filled' as a color
John W. Eaton <jwe@octave.org>
parents:
11589
diff
changeset
|
74 elseif (firstnonnumeric == istart && ischar (varargin{istart}) |
cd82f5933c73
scatter: don't recognize 'filled' as a color
John W. Eaton <jwe@octave.org>
parents:
11589
diff
changeset
|
75 && ! strcmpi (varargin{istart}, "filled")) |
10697
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
76 c = varargin{istart}; |
7189 | 77 firstnonnumeric++; |
78 else | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
79 c = []; |
7189 | 80 endif |
81 | |
82 newargs = {}; | |
83 filled = false; | |
84 have_marker = false; | |
85 marker = "o"; | |
86 iarg = firstnonnumeric; | |
87 while (iarg <= nargin) | |
7191 | 88 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
|
89 if (ischar (arg) && strncmpi (arg, "filled", 6)) |
7189 | 90 filled = true; |
7768
a2d9f325b65a
Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents:
7603
diff
changeset
|
91 elseif ((ischar (arg) || iscell (arg)) && ! have_marker) |
8257 | 92 [linespec, valid] = __pltopt__ (fcn, arg, false); |
7189 | 93 if (valid) |
10549 | 94 have_marker = true; |
95 marker = linespec.marker; | |
96 if (strncmp (marker, "none", 4)) | |
97 marker = "o"; | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
98 elseif (isempty (marker)) |
10701
657e63dcfd88
scatter.m: Properly set default value markersize and marker type.
Ben Abbott <bpabbott@mac.com>
parents:
10697
diff
changeset
|
99 have_marker = false; |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
100 [dummy, marker] = __next_line_style__ (); |
10549 | 101 endif |
7189 | 102 else |
10549 | 103 error ("%s: invalid linespec", fcn); |
7189 | 104 endif |
105 else | |
106 newargs{end+1} = arg; | |
107 if (iarg <= nargin) | |
10701
657e63dcfd88
scatter.m: Properly set default value markersize and marker type.
Ben Abbott <bpabbott@mac.com>
parents:
10697
diff
changeset
|
108 newargs{end+1} = varargin{iarg++}; |
7189 | 109 endif |
110 endif | |
111 endwhile | |
112 | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
113 if (isempty (c)) |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
114 c = __next_line_color__(); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
115 endif |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
116 |
8257 | 117 hg = hggroup (); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
118 newargs = __add_datasource__ (fcn, hg, {"x", "y", "z", "c", "size"}, |
10549 | 119 newargs{:}); |
8257 | 120 |
121 addproperty ("xdata", hg, "data", x); | |
122 addproperty ("ydata", hg, "data", y); | |
123 addproperty ("zdata", hg, "data", z); | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
124 if (ischar (c)) |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
125 addproperty ("cdata", hg, "data", __color_str_rgb__ (c)); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
126 else |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
127 addproperty ("cdata", hg, "data", c); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
128 endif |
10078 | 129 addproperty ("sizedata", hg, "data", s); |
8257 | 130 addlistener (hg, "xdata", @update_data); |
131 addlistener (hg, "ydata", @update_data); | |
132 addlistener (hg, "zdata", @update_data); | |
133 addlistener (hg, "cdata", @update_data); | |
134 addlistener (hg, "sizedata", @update_data); | |
135 | |
10083
614ad9e7a17b
use patches again in scatter plots
Jaroslav Hajek <highegg@gmail.com>
parents:
10082
diff
changeset
|
136 if (numel (x) <= 100) |
10078 | 137 |
138 ## For small number of points, we'll construct an object for each point. | |
139 | |
140 if (numel (s) == 1) | |
141 s = repmat (s, numel(x), 1); | |
142 endif | |
143 | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
144 if (ischar (c) || rows(c) == 1) |
10078 | 145 for i = 1 : numel (x) |
146 if (filled) | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
147 h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
148 "faces", 1, "vertices", [x(i), y(i), z(i,:)], |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
149 "facecolor", "none", "edgecolor", "none", |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
150 "marker", marker, "markersize", s(i), |
10697
1215ab6f3491
Honor Matlab color settings for scatter().
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
151 "markeredgecolor", c, "markerfacecolor", c, |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
152 "linestyle", "none"); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
153 else |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
154 h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
155 "faces", 1, "vertices", [x(i), y(i), z(i,:)], |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
156 "facecolor", "none", "edgecolor", "none", |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
157 "marker", marker, "markersize", s(i), |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
158 "markeredgecolor", c, "markerfacecolor", "none", |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
159 "linestyle", "none"); |
10078 | 160 endif |
161 endfor | |
162 else | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
163 for i = 1 : numel (x) |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
164 if (filled) |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
165 h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
166 "faces", 1, "vertices", [x(i), y(i), z(i,:)], |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
167 "facecolor", "none", "edgecolor", "none", |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
168 "marker", marker, "markersize", s(i), |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
169 "markeredgecolor", "none", |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
170 "markerfacecolor", "flat", |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
171 "cdata", c(i,:), "facevertexcdata", c(i,:), |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
172 "linestyle", "none"); |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
173 else |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
174 h = __go_patch__ (hg, "xdata", x(i), "ydata", y(i), "zdata", z(i,:), |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
175 "faces", 1, "vertices", [x(i), y(i), z(i,:)], |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
176 "facecolor", "none", "edgecolor", "none", |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
177 "marker", marker, "markersize", s(i), |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
178 "markeredgecolor", "flat", |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
179 "markerfacecolor", "none", |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
180 "cdata", c(i,:), "facevertexcdata", c(i,:), |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
181 "linestyle", "none"); |
10078 | 182 |
183 endif | |
184 endfor | |
185 endif | |
186 | |
8257 | 187 else |
10078 | 188 |
189 ## For larger numbers of points, we split the points by common color. | |
190 | |
191 vert = [x, y, z]; | |
192 | |
193 if (ischar (c) || rows (c) == 1) | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
194 h = render_size_color (hg, vert, s, c, marker, filled, false); |
10236
8e58c402ebb2
Accelerate colormap colored scatter plots
David Bateman <dbateman@free.fr>
parents:
10135
diff
changeset
|
195 elseif (columns (c) == 1) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
196 h = render_size_color (hg, vert, s, c, marker, filled, true); |
10078 | 197 else |
13986
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
198 ## We want to group points by colour. So first get all the unique colours |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
199 [cc, ~, c_to_cc] = unique (c, "rows"); |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
200 |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
201 for i = 1:rows (cc) |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
202 ## Now for each possible unique colour, get the logical index of |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
203 ## points that correspond to that colour |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
204 idx = (i == c_to_cc); |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
205 |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
206 if (isscalar (s)) |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
207 h = render_size_color (hg, vert(idx, :), s, c(idx,:), |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
208 marker, filled, true); |
13986
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
209 else |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
210 h = render_size_color (hg, vert(idx, :), s(idx), c(idx,:), |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
211 marker, filled, true); |
13986
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
212 endif |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
213 endfor |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
214 |
7189 | 215 endif |
10078 | 216 endif |
217 | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
218 if (! ischar (c) && rows (c) > 1) |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
219 ax = get (hg, "parent"); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
220 clim = get (ax, "clim"); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
221 if (min(c(:)) < clim(1)) |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
222 clim(1) = min(c(:)); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
223 set (ax, "clim", clim); |
7189 | 224 endif |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
225 if (max(c(:)) > clim(2)) |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
226 set (ax, "clim", [clim(1), max(c(:))]); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
227 endif |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
228 endif |
7189 | 229 |
8257 | 230 addproperty ("linewidth", hg, "patchlinewidth", 0.5); |
231 addproperty ("marker", hg, "patchmarker", marker); | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
232 if (filled) |
8257 | 233 addproperty ("markeredgecolor", hg, "patchmarkeredgecolor", "none"); |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
234 if (ischar (c) || rows (c) == 1) |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
235 addproperty ("markerfacecolor", hg, "patchmarkerfacecolor", c); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
236 else |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
237 addproperty ("markerfacecolor", hg, "patchmarkerfacecolor", "flat"); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
238 endif |
8257 | 239 else |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
240 addproperty ("markerfacecolor", hg, "patchmarkerfacecolor", "none"); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
241 if (ischar (c) || rows (c) == 1) |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
242 addproperty ("markeredgecolor", hg, "patchmarkeredgecolor", c); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
243 else |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
244 addproperty ("markeredgecolor", hg, "patchmarkeredgecolor", "flat"); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
245 endif |
8257 | 246 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
247 addlistener (hg, "linewidth", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
248 addlistener (hg, "marker", @update_props); |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
249 addlistener (hg, "markerfacecolor", @update_props); |
8257 | 250 addlistener (hg, "markeredgecolor", @update_props); |
251 | |
252 if (! isempty (newargs)) | |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
253 set (hg, newargs{:}); |
8257 | 254 endif |
255 | |
7189 | 256 endfunction |
8257 | 257 |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
258 function h = render_size_color(hg, vert, s, c, marker, filled, isflat) |
10078 | 259 if (isscalar (s)) |
260 x = vert(:,1); | |
261 y = vert(:,2); | |
262 z = vert(:,3:end); | |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
263 if (ischar (c) || !isflat) |
10083
614ad9e7a17b
use patches again in scatter plots
Jaroslav Hajek <highegg@gmail.com>
parents:
10082
diff
changeset
|
264 if (filled) |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
265 h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
266 "faces", 1:numel(x), "vertices", vert, |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
267 "facecolor", "none", "edgecolor", "none", |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
268 "marker", marker, |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
269 "markeredgecolor", "none", |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
270 "markerfacecolor", c, |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
271 "markersize", s, "linestyle", "none"); |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
272 else |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
273 h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
274 "faces", 1:numel(x), "vertices", vert, |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
275 "facecolor", "none", "edgecolor", "none", |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
276 "marker", marker, |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
277 "markeredgecolor", c, |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
278 "markerfacecolor", "none", |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
279 "markersize", s, "linestyle", "none"); |
10083
614ad9e7a17b
use patches again in scatter plots
Jaroslav Hajek <highegg@gmail.com>
parents:
10082
diff
changeset
|
280 endif |
614ad9e7a17b
use patches again in scatter plots
Jaroslav Hajek <highegg@gmail.com>
parents:
10082
diff
changeset
|
281 else |
614ad9e7a17b
use patches again in scatter plots
Jaroslav Hajek <highegg@gmail.com>
parents:
10082
diff
changeset
|
282 if (filled) |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
283 h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
284 "faces", 1:numel(x), "vertices", vert, |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
285 "facecolor", "none", "edgecolor", "none", |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
286 "marker", marker, "markersize", s, |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
287 "markeredgecolor", "none", |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
288 "markerfacecolor", "flat", |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
289 "cdata", c, "facevertexcdata", c(:), |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
290 "linestyle", "none"); |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
291 else |
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
292 h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
293 "faces", 1:numel(x), "vertices", vert, |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
294 "facecolor", "none", "edgecolor", "none", |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
295 "marker", marker, "markersize", s, |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
296 "markeredgecolor", "flat", |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
297 "markerfacecolor", "none", |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
298 "cdata", c, "facevertexcdata", c(:), |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
299 "linestyle", "none"); |
10083
614ad9e7a17b
use patches again in scatter plots
Jaroslav Hajek <highegg@gmail.com>
parents:
10082
diff
changeset
|
300 endif |
10078 | 301 endif |
302 else | |
303 ## FIXME: round the size to one decimal place. It's not quite right, though. | |
13986
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
304 [ss, ~, s_to_ss] = unique (ceil (s*10) / 10); |
10078 | 305 for i = 1:rows (ss) |
13986
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
306 idx = (i == s_to_ss); |
6be49527e4cf
Fix coloured scatter when using more than 100 points (bug #34936)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13141
diff
changeset
|
307 h = render_size_color (hg, vert(idx,:), ss(i), c, |
10135
4516a0c97ced
Handle linestyleorder. Remove @ markers. Treat edgecolor, markeredgecolor and markerfacecolor correctly in scatter.
David Bateman <dbateman@free.fr>
parents:
10083
diff
changeset
|
308 marker, filled, isflat); |
10078 | 309 endfor |
310 endif | |
311 endfunction | |
312 | |
8257 | 313 function update_props (h, d) |
314 lw = get (h, "linewidth"); | |
315 m = get (h, "marker"); | |
316 fc = get (h, "markerfacecolor"); | |
317 ec = get (h, "markeredgecolor"); | |
318 kids = get (h, "children"); | |
319 | |
320 for i = 1 : numel (kids) | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
321 set (kids (i), "linewidth", lw, "marker", m, "markerfacecolor", fc, |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
322 "edgecolor", ec); |
8257 | 323 endfor |
324 endfunction | |
325 | |
326 function update_data (h, d) | |
327 x1 = get (h, "xdata"); | |
328 y1 = get (h, "ydata"); | |
329 z1 = get (h, "zdata"); | |
330 c1 = get (h, "cdata"); | |
331 if (!ischar (c1) && rows (c1) == 1) | |
332 c1 = repmat (c1, numel (x1), 1); | |
333 endif | |
334 size1 = get (h, "sizedata"); | |
335 if (numel (size1) == 1) | |
336 size1 = repmat (size1, numel (x1), 1); | |
337 endif | |
338 hlist = get (h, "children"); | |
339 if (ischar (c1)) | |
9085
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
340 if (isempty (z1)) |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
341 for i = 1 : length (hlist) |
10549 | 342 set (hlist(i), "vertices", [x1(i), y1(i)], "cdata", c1, |
343 "markersize", size1(i)); | |
9085
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
344 endfor |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
345 else |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
346 for i = 1 : length (hlist) |
10549 | 347 set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata", c1, |
348 "markersize", size1(i)); | |
9085
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
349 endfor |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
350 endif |
8257 | 351 else |
9085
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
352 if (isempty (z1)) |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
353 for i = 1 : length (hlist) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
354 set (hlist(i), "vertices", [x1(i), y1(i)], "cdata", |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
12446
diff
changeset
|
355 reshape(c1(i,:),[1, size(c1)(2:end)]), |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
356 "facevertexcdata", c1(i,:), |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
357 "markersize", size1(i)); |
9085
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
358 endfor |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
359 else |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
360 for i = 1 : length (hlist) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
361 set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata", |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
12446
diff
changeset
|
362 reshape(c1(i,:),[1, size(c1)(2:end)]), |
12446
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
363 "facevertexcdata", c1(i,:), |
f899f451fe76
Fix for fltk patch markers (#31801)
David Bateman <dbateman@free.fr>
parents:
12124
diff
changeset
|
364 "markersize", size1(i)); |
9085
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
365 endfor |
136e72b9afa8
correct indexing of cdata for scatter
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
366 endif |
8257 | 367 endif |
368 endfunction |