# HG changeset patch # User Rik # Date 1381272638 25200 # Node ID 3f8b3588a9f068979f15e91a7f75c4e2e97e292a # Parent ec31ca0a581253c99a1c0b0f6ee9106a8127e331 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. diff -r ec31ca0a5812 -r 3f8b3588a9f0 scripts/plot/draw/fill.m --- 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