7170
|
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 [c, h] = __contour__ (varargin) |
|
22 |
7208
|
23 ax = varargin{1}; |
|
24 z = varargin{2}; |
7170
|
25 |
7317
|
26 linespec.linestyle = "-"; |
|
27 linespec.color = "flat"; |
|
28 for i = 3 : nargin |
|
29 arg = varargin {i}; |
|
30 if ((ischar (arg) || iscell (arg))) |
|
31 [linespec, valid] = __pltopt__ ("quiver", arg, false); |
|
32 if (isempty (linespec.color)) |
|
33 linespec.color = "flat"; |
|
34 endif |
|
35 if (valid) |
|
36 have_line_spec = true; |
|
37 varargin(i) = []; |
|
38 break; |
|
39 endif |
|
40 endif |
|
41 endfor |
|
42 |
7175
|
43 if (ischar (z)) |
|
44 if (strcmp (z, "none")) |
|
45 z = NaN; |
|
46 elseif (strcmp (z, "base")) |
7317
|
47 if (nargin < 3) |
7208
|
48 z = varargin{1}; |
7175
|
49 else |
7208
|
50 z = varargin{3}; |
7175
|
51 endif |
7191
|
52 z = 2 * (min (z(:)) - max (z(:))); |
|
53 elseif (! strcmp (z, "level")) |
7175
|
54 error ("unrecognized z argument"); |
|
55 endif |
|
56 endif |
|
57 |
7170
|
58 [c, lev] = contourc (varargin{3:end}); |
|
59 |
|
60 ## Decode contourc output format. |
|
61 i1 = 1; |
|
62 h = []; |
|
63 while (i1 < length (c)) |
|
64 clev = c(1,i1); |
|
65 clen = c(2,i1); |
|
66 |
7175
|
67 if (all (c(:,i1+1) == c(:,i1+clen))) |
|
68 p = c(:, i1+1:i1+clen-1); |
|
69 else |
|
70 p = [c(:, i1+1:i1+clen), NaN(2, 1)]; |
|
71 endif |
|
72 |
7170
|
73 if (isnan (z)) |
7175
|
74 h = [h; patch(ax, p(1,:), p(2,:), "facecolor", "none", |
7317
|
75 "edgecolor", linespec.color, "linestyle", |
|
76 linespec.linestyle, "cdata", clev)]; |
7175
|
77 elseif (!ischar(z)) |
|
78 h = [h; patch(ax, p(1,:), p(2,:), z * ones (1, columns (p)), "facecolor", |
7317
|
79 "none", "edgecolor", linespec.color, |
|
80 "linestyle", linespec.linestyle, "cdata", clev)]; |
7170
|
81 else |
7175
|
82 h = [h; patch(ax, p(1,:), p(2,:), clev * ones (1, columns (p)), |
7317
|
83 "facecolor", "none", "edgecolor", linespec.color, |
|
84 "linestyle", linespec.linestyle, "cdata", clev)]; |
7170
|
85 endif |
|
86 i1 += clen+1; |
|
87 endwhile |
|
88 |
|
89 endfunction |