Mercurial > hg > octave-lojdl
changeset 12524:482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sat, 19 Mar 2011 11:07:52 -0400 |
parents | 33f7d8f95f5b |
children | d36266a54202 |
files | scripts/ChangeLog scripts/geometry/trisurf.m |
diffstat | 2 files changed, 42 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2011-03-19 Ben Abbott <bpabbott@mac.com> + + * geometry/trisurf.m: Set default edgecolor as Matlab does. Add demos. + 2010-03-18 Rik <octave@nomad.inbox5.com> * plot/uigetdir.m, plot/uigetfile.m, plot/uimenu.m, plot/uiputfile.m:
--- a/scripts/geometry/trisurf.m +++ b/scripts/geometry/trisurf.m @@ -27,7 +27,7 @@ ## @seealso{triplot, trimesh, delaunay3} ## @end deftypefn -function h = trisurf (tri, x, y, z, varargin) +function varargout = trisurf (tri, x, y, z, varargin) if (nargin < 3) print_usage (); @@ -44,18 +44,22 @@ else c = z; endif - + if (! any (strcmpi (varargin, "FaceColor"))) + nfc = numel (varargin) + 1; + varargin(nfc+(0:1)) = {"FaceColor", "flat"}; + else + nfc = find (any (strcmpi (varargin, "FaceColor")), 1); + endif + if (! any (strcmpi (varargin, "EdgeColor")) + && strcmpi (varargin{nfc+1}, "interp")) + varargin(end+(1:2)) = {"EdgeColor", "none"}; + endif newplot (); + h = patch ("Faces", tri, "Vertices", [x(:), y(:), z(:)], + "FaceVertexCData", reshape (c, numel (c), 1), + varargin{:}); if (nargout > 0) - h = patch ("Faces", tri, "Vertices", [x(:), y(:), z(:)], - "FaceVertexCData", reshape (c, numel (c), 1), - "FaceColor", "flat", "EdgeColor", "none", - varargin{:}); - else - patch ("Faces", tri, "Vertices", [x(:), y(:), z(:)], - "FaceVertexCData", reshape (c, numel (c), 1), - "FaceColor", "flat", "EdgeColor", "none", - varargin{:}); + varargout = {h}; endif if (! ishold ()) @@ -73,3 +77,26 @@ %! z = peaks (x, y); %! tri = delaunay (x(:), y(:)); %! trisurf (tri, x(:), y(:), z(:)); + +%!demo +%! x = rand (100, 1); +%! y = rand (100, 1); +%! z = x.^2 + y.^2; +%! tri = delaunay (x, y); +%! trisurf (tri, x, y, z) + +%!demo +%! x = rand (100, 1); +%! y = rand (100, 1); +%! z = x.^2 + y.^2; +%! tri = delaunay (x, y); +%! trisurf (tri, x, y, z, "facecolor", "interp") + +%!demo +%! x = rand (100, 1); +%! y = rand (100, 1); +%! z = x.^2 + y.^2; +%! tri = delaunay (x, y); +%! trisurf (tri, x, y, z, "facecolor", "interp", "edgecolor", "k") + +