# HG changeset patch # User Rik # Date 1330898262 28800 # Node ID f22a9555aa690033ae746834d76e1ace55308720 # Parent df5488e46dca4559cfbd9b4808cfca14cf412c7a Fix 2D plotting of boolean values (bug #33607) __plt__.m: Promote booleans to int8 values for plotting. diff --git a/scripts/plot/private/__plt__.m b/scripts/plot/private/__plt__.m --- a/scripts/plot/private/__plt__.m +++ b/scripts/plot/private/__plt__.m @@ -177,14 +177,17 @@ [nr, nc] = size (x1); if (nr == 1) x1 = x1.'; - tmp = nr; - nr = nc; - nc = tmp; + [nr, nc] = deal (nc, nr); # Swap rows and columns endif - x1_i = imag (x1); - if (any (any (x1_i))) - x2 = x1_i; - x1 = real (x1); + if (iscomplex (x1)) + x1_i = imag (x1); + if (any ((x1_i(:)))) + x2 = x1_i; + x1 = real (x1); + else + x2 = x1; + x1 = (1:nr)'; + endif else x2 = x1; x1 = (1:nr)'; @@ -212,11 +215,15 @@ error ("__plt1__: options must be a struct array"); endif - if (any (any (imag (x1)))) + if (islogical (x1)) + x1 = int8 (x1); + elseif (iscomplex ((x1))) x1 = real (x1); endif - if (any (any (imag (x2)))) + if (islogical (x2)) + x2 = int8 (x2); + elseif (iscomplex (x2)) x2 = real (x2); endif