annotate scripts/plot/__contour__.m @ 7208:a730e47fda4d

[project @ 2007-11-28 02:32:41 by jwe]
author jwe
date Wed, 28 Nov 2007 02:32:42 +0000
parents b48a21816f2e
children 11c5f1ee553e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 2007 David Bateman
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
2 ##
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
4 ##
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
8 ## your option) any later version.
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
9 ##
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
14 ##
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
18
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
19 ## Undocumented internal function.
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
20
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
21 function [c, h] = __contour__ (varargin)
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
22
7208
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7191
diff changeset
23 ax = varargin{1};
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7191
diff changeset
24 z = varargin{2};
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
25
7175
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
26 if (ischar (z))
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
27 if (strcmp (z, "none"))
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
28 z = NaN;
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
29 elseif (strcmp (z, "base"))
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
30 if (nargin == 1)
7208
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7191
diff changeset
31 z = varargin{1};
7175
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
32 else
7208
a730e47fda4d [project @ 2007-11-28 02:32:41 by jwe]
jwe
parents: 7191
diff changeset
33 z = varargin{3};
7175
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
34 endif
7191
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
35 z = 2 * (min (z(:)) - max (z(:)));
b48a21816f2e [project @ 2007-11-26 21:24:32 by jwe]
jwe
parents: 7189
diff changeset
36 elseif (! strcmp (z, "level"))
7175
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
37 error ("unrecognized z argument");
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
38 endif
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
39 endif
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
40
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
41 [c, lev] = contourc (varargin{3:end});
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
42
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
43 ## Decode contourc output format.
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
44 i1 = 1;
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
45 h = [];
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
46 while (i1 < length (c))
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
47 clev = c(1,i1);
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
48 clen = c(2,i1);
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
49
7175
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
50 if (all (c(:,i1+1) == c(:,i1+clen)))
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
51 p = c(:, i1+1:i1+clen-1);
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
52 else
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
53 p = [c(:, i1+1:i1+clen), NaN(2, 1)];
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
54 endif
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
55
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
56 if (isnan (z))
7175
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
57 h = [h; patch(ax, p(1,:), p(2,:), "facecolor", "none",
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7175
diff changeset
58 "edgecolor", "flat", "cdata", clev)];
7175
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
59 elseif (!ischar(z))
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
60 h = [h; patch(ax, p(1,:), p(2,:), z * ones (1, columns (p)), "facecolor",
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7175
diff changeset
61 "none", "edgecolor", "flat", "cdata", clev)];
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
62 else
7175
5ff4da7bd2e7 [project @ 2007-11-14 20:36:48 by jwe]
jwe
parents: 7170
diff changeset
63 h = [h; patch(ax, p(1,:), p(2,:), clev * ones (1, columns (p)),
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7175
diff changeset
64 "facecolor", "none", "edgecolor", "flat", "cdata", clev)];
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
65 endif
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
66 i1 += clen+1;
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
67 endwhile
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
68
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents:
diff changeset
69 endfunction