Mercurial > octave-nkf
comparison scripts/plot/__contour__.m @ 12068:6624d0ac6a52 release-3-2-x
Fix test for setting of datasource properties. Add the edgecolor property to contours
author | David Bateman <dbateman@free.fr> |
---|---|
date | Mon, 24 Aug 2009 10:02:47 +0200 |
parents | eb63fbe60fab |
children |
comparison
equal
deleted
inserted
replaced
12067:310063a87407 | 12068:6624d0ac6a52 |
---|---|
26 zlevel = varargin{2}; | 26 zlevel = varargin{2}; |
27 filled = "off"; | 27 filled = "off"; |
28 | 28 |
29 linespec.linestyle = "-"; | 29 linespec.linestyle = "-"; |
30 linespec.color = "auto"; | 30 linespec.color = "auto"; |
31 edgecolor = "flat"; | |
31 for i = 3 : nargin | 32 for i = 3 : nargin |
32 arg = varargin {i}; | 33 arg = varargin {i}; |
33 if ((ischar (arg) || iscell (arg))) | 34 if ((ischar (arg) || iscell (arg))) |
34 [linespec, valid] = __pltopt__ ("__contour__", arg, false); | 35 [linespec, valid] = __pltopt__ ("__contour__", arg, false); |
35 if (isempty (linespec.color)) | 36 if (isempty (linespec.color)) |
50 if (strcmpi (varargin{i}, "fill")) | 51 if (strcmpi (varargin{i}, "fill")) |
51 filled = varargin {i + 1}; | 52 filled = varargin {i + 1}; |
52 varargin(i:i+1) = []; | 53 varargin(i:i+1) = []; |
53 elseif (strcmpi (varargin{i}, "linecolor")) | 54 elseif (strcmpi (varargin{i}, "linecolor")) |
54 linespec.color = varargin {i + 1}; | 55 linespec.color = varargin {i + 1}; |
56 edgecolor = linespec.color; | |
57 if (ischar (edgecolor) && strcmpi (edgecolor, "auto")) | |
58 edgecolor = "flat"; | |
59 endif | |
60 varargin(i:i+1) = []; | |
61 elseif (strcmpi (varargin{i}, "edgecolor")) | |
62 linespec.color = varargin {i + 1}; | |
63 edgecolor = linespec.color; | |
64 if (ischar (edgecolor) && strcmpi (edgecolor, "flat")) | |
65 linespec.color = "auto"; | |
66 endif | |
55 varargin(i:i+1) = []; | 67 varargin(i:i+1) = []; |
56 else | 68 else |
57 opts{end+1} = varargin{i}; | 69 opts{end+1} = varargin{i}; |
58 varargin(i) = []; | 70 varargin(i) = []; |
59 opts{end+1} = varargin{i}; | 71 opts{end+1} = varargin{i}; |
162 | 174 |
163 addproperty ("linecolor", hg, "color", linespec.color, "{auto}|none"); | 175 addproperty ("linecolor", hg, "color", linespec.color, "{auto}|none"); |
164 addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle); | 176 addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle); |
165 addproperty ("linewidth", hg, "linelinewidth", 0.5); | 177 addproperty ("linewidth", hg, "linelinewidth", 0.5); |
166 | 178 |
179 ## FIXME It would be good to hide this property which is just an undocumented | |
180 ## alias for linecolor | |
181 addproperty ("edgecolor", hg, "color", edgecolor, "{flat}|none"); | |
182 | |
167 addlistener (hg, "fill", @update_data); | 183 addlistener (hg, "fill", @update_data); |
168 | 184 |
169 addlistener (hg, "zlevelmode", @update_zlevel); | 185 addlistener (hg, "zlevelmode", @update_zlevel); |
170 addlistener (hg, "zlevel", @update_zlevel); | 186 addlistener (hg, "zlevel", @update_zlevel); |
171 | 187 |
182 addlistener (hg, "showtext", @update_text); | 198 addlistener (hg, "showtext", @update_text); |
183 | 199 |
184 addlistener (hg, "linecolor", @update_line); | 200 addlistener (hg, "linecolor", @update_line); |
185 addlistener (hg, "linestyle", @update_line); | 201 addlistener (hg, "linestyle", @update_line); |
186 addlistener (hg, "linewidth", @update_line); | 202 addlistener (hg, "linewidth", @update_line); |
203 | |
204 addlistener (hg, "edgecolor", @update_edgecolor); | |
187 | 205 |
188 add_patch_children (hg); | 206 add_patch_children (hg); |
189 | 207 |
190 if (!isempty (opts)) | 208 if (!isempty (opts)) |
191 set (hg, opts{:}); | 209 set (hg, opts{:}); |
364 set (kids(i), "zdata", z .* ones (size (get (kids (i), "xdata")))); | 382 set (kids(i), "zdata", z .* ones (size (get (kids (i), "xdata")))); |
365 endfor | 383 endfor |
366 endswitch | 384 endswitch |
367 endfunction | 385 endfunction |
368 | 386 |
387 function update_edgecolor (h, d) | |
388 ec = get (h, "edgecolor"); | |
389 lc = get (h, "linecolor"); | |
390 if (ischar (ec) && strcmpi (ec, "flat")) | |
391 if (! strcmpi (lc, "auto")) | |
392 set (h, "linecolor", "auto"); | |
393 endif | |
394 elseif (! isequal (ec, lc)) | |
395 set (h, "linecolor", ec); | |
396 endif | |
397 endfunction | |
398 | |
369 function update_line (h, d) | 399 function update_line (h, d) |
370 lc = get (h, "linecolor"); | 400 lc = get (h, "linecolor"); |
401 ec = get (h, "edgecolor"); | |
371 if (strcmpi (lc, "auto")) | 402 if (strcmpi (lc, "auto")) |
372 lc = "flat"; | 403 lc = "flat"; |
404 endif | |
405 if (! isequal (ec, lc)) | |
406 set (h, "edgecolor", lc); | |
373 endif | 407 endif |
374 set (findobj (h, "type", "patch"), "edgecolor", lc, | 408 set (findobj (h, "type", "patch"), "edgecolor", lc, |
375 "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle")); | 409 "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle")); |
376 endfunction | 410 endfunction |
377 | 411 |