changeset 22695:d6164341b64d

fill.m: Return one patch handle per polygon created for Matlab compatibility. * fill.m: Use for loop over varargin for datasets, and a second loop over columns of each dataset, to call __patch__ once per polygon. New variable one_color to track whether a single color is used for each polygon. Change variable name 'fail' to 'err' to keep line length < 80.
author Rik <rik@octave.org>
date Fri, 28 Oct 2016 11:37:33 -0700
parents b100f76b991d
children 90c3839825a3
files scripts/plot/draw/fill.m
diffstat 1 files changed, 27 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/draw/fill.m	Fri Oct 28 08:53:03 2016 -0700
+++ b/scripts/plot/draw/fill.m	Fri Oct 28 11:37:33 2016 -0700
@@ -108,20 +108,41 @@
             error ("fill: X annd Y must have same number of rows");
           endif
         endif
+
+        if (isrow (x))
+          x = x(:);
+        endif
+        if (isrow (y))
+          y = y(:);
+        endif
+
+        if (ischar (cdata) || isequal (size (cdata), [1, 3]))
+          one_color = true;
+        else
+          one_color = false;
+        endif
+
         ## For Matlab compatibility, replicate cdata to match size of data
-        if (iscolumn (cdata) && ! ischar (cdata))
+        if (! one_color && iscolumn (cdata))
           sz = size (x);
           if (all (sz > 1))
             cdata = repmat (cdata, [1, sz(2)]);
           endif
         endif
 
-        [htmp, fail] = __patch__ (hax, x, y, cdata, opts{:});
-        if (fail)
-          print_usage ();
-        endif
+        ## For Matlab compatibility, return 1 patch object for each column
+        for j = 1 : columns (x)
+          if (one_color)
+            [htmp, err] = __patch__ (hax, x(:,j), y(:,j), cdata, opts{:});
+          else
+            [htmp, err] = __patch__ (hax, x(:,j), y(:,j), cdata(:,j), opts{:});
+          endif
+          if (err)
+            print_usage ();
+          endif
+          hlist(end+1, 1) = htmp;
+        endfor
 
-        hlist(end+1, 1) = htmp;
       endfor
 
     unwind_protect_cleanup