# HG changeset patch # User Ben Abbott # Date 1300547272 14400 # Node ID 482cf3aad91501b6a181541bf78c335d78839bb3 # Parent 33f7d8f95f5bb28e79fce20c711f16c08d41204c trisurf.m: Set default edgecolor as Matlab does. Add demos. diff -r 33f7d8f95f5b -r 482cf3aad915 scripts/ChangeLog --- a/scripts/ChangeLog Fri Mar 18 22:58:18 2011 -0700 +++ b/scripts/ChangeLog Sat Mar 19 11:07:52 2011 -0400 @@ -1,3 +1,7 @@ +2011-03-19 Ben Abbott + + * geometry/trisurf.m: Set default edgecolor as Matlab does. Add demos. + 2010-03-18 Rik * plot/uigetdir.m, plot/uigetfile.m, plot/uimenu.m, plot/uiputfile.m: diff -r 33f7d8f95f5b -r 482cf3aad915 scripts/geometry/trisurf.m --- a/scripts/geometry/trisurf.m Fri Mar 18 22:58:18 2011 -0700 +++ b/scripts/geometry/trisurf.m Sat Mar 19 11:07:52 2011 -0400 @@ -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") + +