Mercurial > hg > octave-nkf
annotate scripts/plot/__contour__.m @ 8046:c4482fc30c7f
Add the ezplot function
author | David Bateman <dbateman@free.fr> |
---|---|
date | Thu, 21 Aug 2008 11:29:06 -0400 |
parents | dfcaf7ed48e3 |
children | 73d6b71788c0 |
rev | line source |
---|---|
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))) | |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
31 [linespec, valid] = __pltopt__ ("contour", arg, false); |
7317 | 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 | |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
43 opts = {}; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
44 i = 3; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
45 while (i < length (varargin)) |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
46 if (ischar (varargin {i})) |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
47 opts{end+1} = varargin{i}; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
48 varargin(i) = []; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
49 opts{end+1} = varargin{i}; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
50 varargin(i) = []; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
51 else |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
52 i++; |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
53 endif |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
54 endwhile |
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
55 |
7175 | 56 if (ischar (z)) |
57 if (strcmp (z, "none")) | |
58 z = NaN; | |
59 elseif (strcmp (z, "base")) | |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
60 z = varargin{3}; |
7191 | 61 z = 2 * (min (z(:)) - max (z(:))); |
62 elseif (! strcmp (z, "level")) | |
7175 | 63 error ("unrecognized z argument"); |
64 endif | |
65 endif | |
66 | |
7170 | 67 [c, lev] = contourc (varargin{3:end}); |
68 | |
69 ## Decode contourc output format. | |
70 i1 = 1; | |
71 h = []; | |
72 while (i1 < length (c)) | |
73 clev = c(1,i1); | |
74 clen = c(2,i1); | |
75 | |
7175 | 76 if (all (c(:,i1+1) == c(:,i1+clen))) |
77 p = c(:, i1+1:i1+clen-1); | |
78 else | |
79 p = [c(:, i1+1:i1+clen), NaN(2, 1)]; | |
80 endif | |
81 | |
7170 | 82 if (isnan (z)) |
7175 | 83 h = [h; patch(ax, p(1,:), p(2,:), "facecolor", "none", |
7317 | 84 "edgecolor", linespec.color, "linestyle", |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
85 linespec.linestyle, "cdata", clev, opts{:})]; |
7175 | 86 elseif (!ischar(z)) |
87 h = [h; patch(ax, p(1,:), p(2,:), z * ones (1, columns (p)), "facecolor", | |
7317 | 88 "none", "edgecolor", linespec.color, |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
89 "linestyle", linespec.linestyle, "cdata", clev, opts{:})]; |
7170 | 90 else |
7175 | 91 h = [h; patch(ax, p(1,:), p(2,:), clev * ones (1, columns (p)), |
7317 | 92 "facecolor", "none", "edgecolor", linespec.color, |
7462
dfcaf7ed48e3
Allow linewidth to be specified for contours
David Bateman
parents:
7317
diff
changeset
|
93 "linestyle", linespec.linestyle, "cdata", clev, opts{:})]; |
7170 | 94 endif |
95 i1 += clen+1; | |
96 endwhile | |
97 | |
98 endfunction |