changeset 24408:a9be96afb39e stable

Set gnuplot color data to half output range when autoscaling zero input range (bug #52624). * __gnuplot_draw_axes__.m: Ensure cbrange is not zero when cmap_sz is 1 by using 2 instead to avoid gnuplot error. (mapcdata): When the clim range is zero, set cdata to half range in both the TrueColor and colormap cases using the proper truncation of fraction.
author Daniel J Sebald <daniel.sebald@ieee.org>
date Tue, 12 Dec 2017 22:10:59 -0600
parents 5528840346e7
children ca0ebd1d0da1 6e1d3ad32ed1
files scripts/plot/util/private/__gnuplot_draw_axes__.m
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/private/__gnuplot_draw_axes__.m	Wed Dec 13 08:33:09 2017 -0800
+++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m	Tue Dec 12 22:10:59 2017 -0600
@@ -1471,7 +1471,7 @@
       fprintf (plot_stream, "set cbrange [1:%.15e];\n",
                cmap_sz + rows (addedcmap));
     else
-      fprintf (plot_stream, "set cbrange [1:%.15e];\n", cmap_sz);
+      fprintf (plot_stream, "set cbrange [1:%.15e];\n", max ([cmap_sz 2]));
     endif
   endif
 
@@ -2878,7 +2878,7 @@
       cdata = 255 * (cdata - clim(1)) / clim_rng;
       cdata(cdata < 0) = 0;  cdata(cdata > 255) = 255;
     else
-      cdata(:) = 255;
+      cdata(:) = fix (255 / 2);
     endif
   else
     if (islogical (cdata))
@@ -2890,7 +2890,7 @@
       if (clim_rng != 0)
         cdata = 1 + fix (cmap_sz * (cdata - clim(1)) / clim_rng);
       else
-        cdata(:) = cmap_sz;
+        cdata(:) = 1 + fix (cmap_sz / 2);
       endif
     else
       if (isinteger (cdata))