changeset 26233:59bc720d1bf9

Fix scatter plots with a mix of float and integer inputs (bug #41166). * __scatter__.m: During input validation cast mixed data of floating point and integer to floating point.
author Rik <rik@octave.org>
date Thu, 13 Dec 2018 22:58:37 -0800
parents 90487d5431cc
children 23b56a61c918
files scripts/plot/draw/private/__scatter__.m
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/draw/private/__scatter__.m	Thu Dec 13 19:00:28 2018 -0800
+++ b/scripts/plot/draw/private/__scatter__.m	Thu Dec 13 22:58:37 2018 -0800
@@ -36,6 +36,25 @@
     istart = 7;
   endif
 
+  ## Force mixtures of int and float data to be float (Bug #4116).
+  if (xor (isfloat (x), isfloat (y)))
+    if (isfloat (x))
+      y = cast (y, class (x));
+    else
+      x = cast (x, class (y));
+    endif
+  endif
+  if (nd != 2)
+    if (xor (isfloat (x), isfloat (z)))
+      if (isfloat (x))
+        z = cast (z, class (x));
+      else
+        x = cast (x, class (z));
+        y = cast (y, class (z));
+      endif
+    endif
+  endif
+
   if (istart <= nargin)
     s = varargin{istart}(:);
     if (isempty (s) || ischar (s))