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}) |
6257
|
25 ## |
6604
|
26 ## Plot level curves (contour lines) of the matrix @var{z}, using the |
|
27 ## contour matrix @var{c} computed by @code{contourc} from the same |
|
28 ## arguments; see the latter for their interpretation. @var{c} is only |
|
29 ## returned if requested. For example: |
6257
|
30 ## |
|
31 ## @example |
6604
|
32 ## @group |
|
33 ## x = 0:2; |
|
34 ## y = x; |
|
35 ## z = x' * y; |
|
36 ## contour (x, y, z, 2:3) |
6257
|
37 ## |
6604
|
38 ## @end group |
6257
|
39 ## @end example |
6547
|
40 ## @seealso{contourc, line, plot} |
3368
|
41 ## @end deftypefn |
4
|
42 |
6257
|
43 ## Author: shaia |
|
44 |
|
45 function retval = contour (varargin) |
4
|
46 |
6257
|
47 [c, lev] = contourc (varargin{:}); |
6172
|
48 |
6257
|
49 cmap = get (gcf(), "colormap"); |
|
50 |
|
51 levx = linspace (min (lev), max (lev), size (cmap, 1)); |
|
52 |
|
53 newplot (); |
3063
|
54 |
6434
|
55 ## Decode contourc output format. |
6257
|
56 i1 = 1; |
|
57 while (i1 < length (c)) |
6434
|
58 |
6257
|
59 clev = c(1,i1); |
|
60 clen = c(2,i1); |
|
61 |
|
62 ccr = interp1 (levx, cmap(:,1), clev); |
|
63 ccg = interp1 (levx, cmap(:,2), clev); |
|
64 ccb = interp1 (levx, cmap(:,3), clev); |
|
65 |
|
66 ii = i1+1:i1+clen; |
6279
|
67 line (c(1,ii), c(2,ii), "color", [ccr, ccg, ccb]); |
6257
|
68 |
|
69 i1 += c(2,i1)+1; |
|
70 endwhile |
|
71 |
|
72 if (nargout > 0) |
|
73 retval = c; |
4
|
74 endif |
|
75 |
|
76 endfunction |
6257
|
77 |
|
78 |