Mercurial > hg > octave-lyh
annotate scripts/plot/__scatter__.m @ 8232:c6e9ff62c64a
Fix subplot for column vector of children in figure
author | David Bateman <dbateman@free.fr> |
---|---|
date | Thu, 16 Oct 2008 16:23:14 -0400 |
parents | 73d6b71788c0 |
children | 79c874fe5100 |
rev | line source |
---|---|
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) | |
7191 | 22 |
23 h = varargin{1}; | |
24 nd = varargin{2}; | |
25 fcn = varargin{3}; | |
26 x = varargin{4}(:); | |
27 y = varargin{5}(:); | |
7189 | 28 istart = 6; |
7191 | 29 |
7189 | 30 if (nd == 3) |
7191 | 31 z = varargin{6}(:); |
7421 | 32 idx = isnan(x) | isnan (y) | isnan (z); |
33 x (idx) = []; | |
34 y (idx) = []; | |
35 z (idx) = []; | |
7189 | 36 istart = 7; |
37 else | |
7421 | 38 idx = isnan(x) | isnan (y); |
39 x (idx) = []; | |
40 y (idx) = []; | |
7191 | 41 z = zeros (length (x), 0); |
7189 | 42 endif |
43 | |
44 firstnonnumeric = Inf; | |
45 for i = istart:nargin | |
7191 | 46 if (! isnumeric (varargin{i})) |
7189 | 47 firstnonnumeric = i; |
48 break; | |
49 endif | |
50 endfor | |
51 | |
7235 | 52 if (istart < nargin && firstnonnumeric > istart) |
7191 | 53 s = varargin{istart}; |
7189 | 54 if (isempty (s)) |
7603
689652eb95d1
fix for scatter markersize
David Bateman <dbateman@free.fr>
parents:
7421
diff
changeset
|
55 s = 6; |
7189 | 56 endif |
57 else | |
7603
689652eb95d1
fix for scatter markersize
David Bateman <dbateman@free.fr>
parents:
7421
diff
changeset
|
58 s = 6; |
7189 | 59 endif |
60 | |
61 if (istart < nargin && firstnonnumeric > istart + 1) | |
7191 | 62 c = varargin{istart + 1}; |
7189 | 63 if (isvector (c)) |
64 c = c(:); | |
65 endif | |
7191 | 66 elseif (firstnonnumeric == istart + 1 && ischar (varargin{istart + 1})) |
7189 | 67 c = varargin{istart + 1}; |
68 firstnonnumeric++; | |
69 else | |
70 c = 1 : length(x); | |
71 endif | |
72 | |
73 newargs = {}; | |
74 filled = false; | |
75 have_marker = false; | |
76 marker = "o"; | |
77 iarg = firstnonnumeric; | |
78 while (iarg <= nargin) | |
7191 | 79 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
|
80 if (ischar (arg) && strncmpi (arg, "filled", 6)) |
7189 | 81 filled = true; |
7768
a2d9f325b65a
Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents:
7603
diff
changeset
|
82 elseif ((ischar (arg) || iscell (arg)) && ! have_marker) |
7189 | 83 [linespec, valid] = __pltopt__ ("scatter", arg, false); |
84 if (valid) | |
85 have_marker = true; | |
86 marker = linespec.marker; | |
87 if (strncmp (marker, "none", 4)) | |
88 marker = "o"; | |
89 endif | |
90 else | |
91 error ("scatter: invalid linespec"); | |
92 endif | |
93 else | |
94 newargs{end+1} = arg; | |
95 if (iarg <= nargin) | |
96 newargs{end+1} = varagin{iarg++}; | |
97 endif | |
98 endif | |
99 endwhile | |
100 | |
101 if (ischar (c)) | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7768
diff
changeset
|
102 h = patch ("faces", [1:length(x)].', "vertices", [x, y, z], "facecolor", |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7768
diff
changeset
|
103 "none", "edgecolor", c, "marker", marker, |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7768
diff
changeset
|
104 "markersize", s, "linestyle", "none"); |
7189 | 105 if (filled) |
7191 | 106 set(h, "markerfacecolor", c); |
7189 | 107 endif |
108 else | |
8190
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7768
diff
changeset
|
109 h = patch ("faces", [1:length(x)].', "vertices", [x, y, z], "facecolor", |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7768
diff
changeset
|
110 "none", "edgecolor", "flat", "cdata", c, "marker", marker, |
73d6b71788c0
use case-insensitive comparison for graphics properties; misc style fixes
John W. Eaton <jwe@octave.org>
parents:
7768
diff
changeset
|
111 "markersize", s, "linestyle", "none"); |
7189 | 112 if (filled) |
7191 | 113 set(h, "markerfacecolor", "flat"); |
7189 | 114 endif |
115 ax = get (h, "parent"); | |
116 clim = get (ax, "clim"); | |
117 if (min(c(:)) < clim(1)) | |
118 clim(1) = min(c(:)); | |
119 set (ax, "clim", clim); | |
120 endif | |
121 if (max(c(:)) > clim(2)) | |
122 set (ax, "clim", [clim(1), max(c(:))]); | |
123 endif | |
124 endif | |
125 | |
126 endfunction |