7017
|
1 ## Copyright (C) 1996, 1997, 2007 John W. Eaton |
6788
|
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 |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
6788
|
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 |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
6788
|
18 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} meshc (@var{x}, @var{y}, @var{z}) |
|
21 ## Plot a mesh and contour given matrices @var{x}, and @var{y} from |
|
22 ## @code{meshgrid} and a matrix @var{z} corresponding to the @var{x} and |
|
23 ## @var{y} coordinates of the mesh. If @var{x} and @var{y} are vectors, |
|
24 ## then a typical vertex is (@var{x}(j), @var{y}(i), @var{z}(i,j)). Thus, |
|
25 ## columns of @var{z} correspond to different @var{x} values and rows of |
|
26 ## @var{z} correspond to different @var{y} values. |
|
27 ## @seealso{meshgrid, mesh, contour} |
|
28 ## @end deftypefn |
|
29 |
|
30 function h = meshc (varargin) |
|
31 |
|
32 newplot (); |
|
33 |
7119
|
34 tmp = surface (varargin{:}); |
|
35 |
|
36 ax = get (tmp, "parent"); |
6788
|
37 |
7119
|
38 set (tmp, "facecolor", "none"); |
|
39 set (tmp, "edgecolor", "flat"); |
6788
|
40 |
7119
|
41 set (ax, "view", [-37.5, 30]); |
6788
|
42 |
|
43 hold on; |
|
44 |
|
45 [c, lev] = contourc (varargin{:}); |
|
46 |
7119
|
47 cmap = get (gcf (), "colormap"); |
6788
|
48 |
|
49 levx = linspace (min (lev), max (lev), size (cmap, 1)); |
|
50 |
|
51 drawnow(); |
|
52 ax = axis(); |
|
53 zmin = 2 * ax(5) - ax(6); |
|
54 |
7119
|
55 ## Decode contourc output format. |
6788
|
56 i1 = 1; |
|
57 while (i1 < length (c)) |
|
58 |
|
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; |
7119
|
67 line (c(1,ii), c(2,ii), zmin * ones (size (ii)), "color", |
|
68 [ccr, ccg, ccb]); |
6788
|
69 |
|
70 i1 += c(2,i1)+1; |
7119
|
71 |
6788
|
72 endwhile |
|
73 |
|
74 if (nargout > 0) |
|
75 h = tmp; |
|
76 endif |
7119
|
77 |
6788
|
78 endfunction |