Mercurial > octave
diff scripts/plot/draw/private/__quiver__.m @ 32062:ada96a467a28
quiver: Improve plotting with non-float numeric inputs (bug #59695)
* scripts/plot/draw/private/__quiver__.m: Change firstnonnumeric check to look
for char instead of numeric to allow for logical inputs. Recast all inputs
up to firstnonnumeric as doubles. Check if firstnonnumeric element is 'off'
and if so set scale factor to 0 and increment firstnonnumeric.
* scripts/plot/draw/quiver.m: Update docstring to include scaling factor
option 'off'. Add BIST for int and logical input types.
* scripts/plot/draw/quiver3.m: Update docstring to include scaling factor
option 'off'. Add BISTs for too-few inputs.
* etc/NEWS.9.md: Appended details of changes to quiver note under General
Improvements and noted it also applies to quiver3.
author | Nicholas R. Jankowski <jankowski.nicholas@gmail.com> |
---|---|
date | Wed, 26 Apr 2023 17:18:50 -0400 |
parents | 29671873411a |
children | 03fe0b635d2e |
line wrap: on
line diff
--- a/scripts/plot/draw/private/__quiver__.m Wed Apr 26 16:29:28 2023 -0700 +++ b/scripts/plot/draw/private/__quiver__.m Wed Apr 26 17:18:50 2023 -0400 @@ -40,12 +40,30 @@ ## in order to get equivalent visual results while keeping equivalent ## property values. arrowsize = 0.20; - - firstnonnumeric = find (! cellfun ("isnumeric", varargin(3:nargin)), 1); + firstnonnumeric = find (cellfun ("ischar", varargin(3:nargin)), 1); if (isempty (firstnonnumeric)) firstnonnumeric = Inf; + + ## Recast non-float inputs as doubles to avoid erroneous plots. + varargin(3:end) = cellfun ('double', varargin(3:end), ... + "UniformOutput", false); else firstnonnumeric += 2; + + ## Recast non-float inputs as doubles. + varargin(3:firstnonnumeric-1) = cellfun ('double', + varargin(3:firstnonnumeric-1), "UniformOutput", false); + + ## Check for scaling factor "off" and set it to 0. + if (strcmpi (varargin{firstnonnumeric}, "off")) + varargin(firstnonnumeric) = 0; + + if ((firstnonnumeric) == nargin) + firstnonnumeric = Inf; + else + firstnonnumeric++; + endif + endif endif ioff = 3;