Mercurial > hg > octave-nkf
changeset 17163:4b834dbe4b3e
meshz.m: Add support for color matrix input.
* scripts/plot/meshz.m: Add support for color matrix input.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 03 Aug 2013 10:05:07 -0700 |
parents | 1e2641277b2a |
children | 36fd98b9ce48 |
files | scripts/plot/meshz.m |
diffstat | 1 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/meshz.m +++ b/scripts/plot/meshz.m @@ -64,8 +64,10 @@ ## Find where property/value pairs start charidx = find (cellfun ("isclass", varargin, "char"), 1); + have_c = false; if (isempty (charidx)) if (nargin == 2 || nargin == 4) + have_c = true; charidx = nargin; # bundle C matrix back into varargin else charidx = nargin + 1; @@ -100,6 +102,15 @@ zref .* ones(rows(z), 1), z, zref .* ones(rows(z), 1); zref .* ones(1, columns(z) + 2)]; + if (have_c) + c = varargin{charidx}; + cref = min (c(isfinite (c))); + c = [cref .* ones(1, columns(c) + 2); + cref .* ones(rows(c), 1), c, cref .* ones(rows(c), 1); + cref .* ones(1, columns(c) + 2)]; + varargin(charidx) = c; + endif + oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); unwind_protect hax = newplot (hax); @@ -116,3 +127,18 @@ endfunction + +%!demo +%! clf; +%! colormap ('default'); +%! Z = peaks (); +%! meshz (Z); + +%!demo +%! clf; +%! colormap ('default'); +%! [X,Y,Z] = peaks (); +%! [fx, fy] = gradient (Z); +%! C = sqrt (fx.^2 + fy.^2); +%! meshz (X,Y,Z,C); +