changeset 17610:3f8b3588a9f0

fill.m: Properly color faces based on orientation of cdata vector. * scripts/plot/draw/fill.m: Test for row vector and set "facecolor" to "flat" if found.
author Rik <rik@octave.org>
date Tue, 08 Oct 2013 15:50:38 -0700
parents ec31ca0a5812
children 0dd2cf2e3174
files scripts/plot/draw/fill.m
diffstat 1 files changed, 29 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/draw/fill.m	Thu May 09 16:14:47 2013 +0200
+++ b/scripts/plot/draw/fill.m	Tue Oct 08 15:50:38 2013 -0700
@@ -74,7 +74,7 @@
 
   opts = {};
   if (numel (varargin) > iargs(end) + 2)
-    opts = varargin(iargs(end) + (3:end));
+    opts = varargin(iargs(end)+3 : end);
   endif
   
   if (! all (cellfun (@(x) iscolorspec (x), varargin(iargs + 2))))
@@ -88,21 +88,33 @@
   unwind_protect
     hax = newplot (hax);
     old_nxtplt = get (hax, "nextplot");
-    set (hax, "nextplot", "add");
+    unwind_protect
+      set (hax, "nextplot", "add");
+
+      for i = 1 : length (iargs)
+        cdata = varargin{iargs(i) + 2};
 
-    for i = 1 : length (iargs)
-      args = [varargin(iargs(i) + (0:2)) opts];
+        ## Matlab uses flat/interp shading based on orientation of cdata.
+        if (isnumeric (cdata) && isrow (cdata))
+          popt = ["facecolor", "flat", opts];
+        else
+          popt = opts;
+        endif
 
-      [htmp, fail] = __patch__ (hax, args{:});
-      if (fail)
-        print_usage ();
+        [htmp, fail] = __patch__ (hax, varargin{iargs(i)+(0:1)}, cdata,
+                                       popt{:});
+        if (fail)
+          print_usage ();
+        endif
+        
+        hlist(end+1, 1) = htmp;
+      endfor
+
+    unwind_protect_cleanup
+      if (strcmp (old_nxtplt, "replace"))
+        set (hax, "nextplot", old_nxtplt);
       endif
-      hlist(end+1, 1) = htmp;
-    endfor
-
-    if (strcmp (old_nxtplt, "replace"))
-      set (hax, "nextplot", old_nxtplt);
-    endif
+    end_unwind_protect
 
   unwind_protect_cleanup
     if (! isempty (oldfig))
@@ -131,10 +143,10 @@
     if (any (strcmpi (arg, colors)))
       retval = true;
     endif
-  elseif (isvector (arg))
-    if (length (arg) == 3 || all (arg >= 0 && arg <=1))
-      retval = true;
-    endif
+  elseif (isnumeric (arg))
+    ## Assume any numeric argument is correctly formatted cdata.
+    ## Let patch worry about the multple different input formats
+    retval = true;
   endif
 endfunction