6257
|
1 ## Copyright (C) 2003 Shai Ayal |
2313
|
2 ## |
6440
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
2313
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
6440
|
10 ## Octave is distributed in the hope that it will be useful, but |
2313
|
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 |
6440
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
245
|
19 |
3368
|
20 ## -*- texinfo -*- |
6888
|
21 ## @deftypefn {Function File} {@var{c} =} contour (@var{z}) |
|
22 ## @deftypefnx {Function File} {@var{c} =} contour (@var{z}, @var{vn}) |
|
23 ## @deftypefnx {Function File} {@var{c} =} contour (@var{x}, @var{y}, @var{z}) |
|
24 ## @deftypefnx {Function File} {@var{c} =} contour (@var{x}, @var{y}, @var{z}, @var{vn}) |
6604
|
25 ## Plot level curves (contour lines) of the matrix @var{z}, using the |
|
26 ## contour matrix @var{c} computed by @code{contourc} from the same |
6895
|
27 ## arguments; see the latter for their interpretation. The set of |
|
28 ## contour levels, @var{c}, is only returned if requested. For example: |
6257
|
29 ## |
|
30 ## @example |
6604
|
31 ## @group |
|
32 ## x = 0:2; |
|
33 ## y = x; |
|
34 ## z = x' * y; |
|
35 ## contour (x, y, z, 2:3) |
6257
|
36 ## |
6604
|
37 ## @end group |
6257
|
38 ## @end example |
6547
|
39 ## @seealso{contourc, line, plot} |
3368
|
40 ## @end deftypefn |
4
|
41 |
6257
|
42 ## Author: shaia |
|
43 |
|
44 function retval = contour (varargin) |
4
|
45 |
6257
|
46 [c, lev] = contourc (varargin{:}); |
6172
|
47 |
6257
|
48 cmap = get (gcf(), "colormap"); |
|
49 |
|
50 levx = linspace (min (lev), max (lev), size (cmap, 1)); |
|
51 |
|
52 newplot (); |
3063
|
53 |
6434
|
54 ## Decode contourc output format. |
6257
|
55 i1 = 1; |
|
56 while (i1 < length (c)) |
6434
|
57 |
6257
|
58 clev = c(1,i1); |
|
59 clen = c(2,i1); |
|
60 |
|
61 ccr = interp1 (levx, cmap(:,1), clev); |
|
62 ccg = interp1 (levx, cmap(:,2), clev); |
|
63 ccb = interp1 (levx, cmap(:,3), clev); |
|
64 |
|
65 ii = i1+1:i1+clen; |
6279
|
66 line (c(1,ii), c(2,ii), "color", [ccr, ccg, ccb]); |
6257
|
67 |
|
68 i1 += c(2,i1)+1; |
|
69 endwhile |
|
70 |
|
71 if (nargout > 0) |
|
72 retval = c; |
4
|
73 endif |
|
74 |
|
75 endfunction |
6257
|
76 |
|
77 |