Mercurial > hg > octave-nkf
diff scripts/plot/meshc.m @ 7119:d22ad51b9cf8
[project @ 2007-11-07 21:06:27 by jwe]
author | jwe |
---|---|
date | Wed, 07 Nov 2007 21:09:05 +0000 |
parents | a1dbe9d80eee |
children | c7e5e638a8d0 |
line wrap: on
line diff
--- a/scripts/plot/meshc.m +++ b/scripts/plot/meshc.m @@ -31,53 +31,20 @@ newplot (); - if (nargin == 1) - z = varargin{1}; - if (ismatrix (z)) - [nr, nc] = size (z); - x = 1:nc; - y = (1:nr)'; - else - error ("meshc: argument must be a matrix"); - endif - elseif (nargin == 3) - x = varargin{1}; - y = varargin{2}; - z = varargin{3}; + tmp = surface (varargin{:}); + + ax = get (tmp, "parent"); - if (isvector (x) && isvector (y) && ismatrix (z)) - if (rows (z) == length (y) && columns (z) == length (x)) - x = x(:)'; - y = y(:); - else - msg = "meshc: rows (z) must be the same as length (y) and"; - msg = sprintf ("%s\ncolumns (z) must be the same as length (x)", msg); - error (msg); - endif - elseif (ismatrix (x) && ismatrix (y) && ismatrix (z)) - if (! (size_equal (x, y) && size_equal (x, z))) - error ("meshc: x, y, and z must have same dimensions"); - endif - else - error ("meshc: x and y must be vectors and z must be a matrix"); - endif - else - print_usage (); - endif + set (tmp, "facecolor", "none"); + set (tmp, "edgecolor", "flat"); - ## make a default line object, and make it the current axes for the - ## current figure. - ca = gca (); - - tmp = __go_surface__ (ca, "xdata", x, "ydata", y, "zdata", z); - - set (ca, "view", [-37.5, 30]); + set (ax, "view", [-37.5, 30]); hold on; [c, lev] = contourc (varargin{:}); - cmap = get (gcf(), "colormap"); + cmap = get (gcf (), "colormap"); levx = linspace (min (lev), max (lev), size (cmap, 1)); @@ -85,7 +52,7 @@ ax = axis(); zmin = 2 * ax(5) - ax(6); - ## decode contourc output format + ## Decode contourc output format. i1 = 1; while (i1 < length (c)) @@ -97,12 +64,15 @@ ccb = interp1 (levx, cmap(:,3), clev); ii = i1+1:i1+clen; - line (c(1,ii), c(2,ii), zmin*ones(size(ii)), "color", [ccr, ccg, ccb]); + line (c(1,ii), c(2,ii), zmin * ones (size (ii)), "color", + [ccr, ccg, ccb]); i1 += c(2,i1)+1; + endwhile if (nargout > 0) h = tmp; endif + endfunction