changeset 22071:7ac3dd72fff9

Fix failing BIST test from cset 9121d6584f6a. * __next_line_color__.m: Handle case where there is only one color in ColorOrder so that mod() returns 0. Reset color_idx to 1 in this case. Rewrite BIST test to show graphically what is happening. * __next_line_style__.m: Handle case where there is only one style in LineStyleOrder. Reset style_idx to 1 in this case. Rewrite BIST test to show graphically what is happening.
author Rik <rik@octave.org>
date Thu, 07 Jul 2016 15:03:10 -0700
parents 3008798dc5ba
children 7680225527ef
files scripts/plot/util/__next_line_color__.m scripts/plot/util/__next_line_style__.m
diffstat 2 files changed, 20 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/__next_line_color__.m	Thu Jul 07 14:57:09 2016 -0700
+++ b/scripts/plot/util/__next_line_color__.m	Thu Jul 07 15:03:10 2016 -0700
@@ -39,10 +39,10 @@
 
   color_idx = fix (get (ca, "colororderindex"));
   num_colors = rows (colororder);
-  if (color_idx > num_colors)
-    color_idx = mod (color_idx, num_colors);
-  endif
-  if (color_idx < 1)
+  color_idx = mod (color_idx, num_colors);
+  if (color_idx == 0)
+    color_idx = num_colors;
+  elseif (color_idx < 0)
     color_idx = 1;
   endif
 
@@ -50,7 +50,10 @@
 
   if (++color_idx > num_colors)
     color_idx = mod (color_idx, num_colors);
-    ## Rollover of all colors switches to next linestyle.
+    if (color_idx == 0)
+      color_idx = 1;
+    endif
+    ## Rollover through all colors also switches to next linestyle.
     style_idx = fix (get (ca, "linestyleorderindex"));
     set (ca, "linestyleorderindex", ++style_idx);
   endif
@@ -65,13 +68,13 @@
 %!   hax = axes ();
 %!   set (hax, "colororder", [1 0 0; 0 1 0; 0 0 1]);
 %!   hold on;
-%!   h = plot (1:5,1:5,'o', 1:4,1:4,"x", 1:3,1:3,"d");
+%!   h = plot (1:2,1:2,"o", 2:3,2:3,"x", 3:4,3:4,"d");
 %!   assert (get (h, "color"), {[1 0 0]; [0 1 0]; [0 0 1]});
 %!   cla (hax);
 %!   hold on;
-%!   h1 = plot (1:5,1:5, 'o');
-%!   h2 = plot (1:4,1:4, "x");
-%!   h3 = plot (1:3,1:3, "d");
+%!   h1 = plot (1:2,1:2, "o");
+%!   h2 = plot (2:3,2:3, "x");
+%!   h3 = plot (3:4,3:4, "d");
 %!   assert (get ([h1;h2;h3], "color"), {[1 0 0]; [0 1 0]; [0 0 1]});
 %! unwind_protect_cleanup
 %!   close (hf);
--- a/scripts/plot/util/__next_line_style__.m	Thu Jul 07 14:57:09 2016 -0700
+++ b/scripts/plot/util/__next_line_style__.m	Thu Jul 07 15:03:10 2016 -0700
@@ -41,10 +41,10 @@
 
   style_idx = fix (get (ca, "linestyleorderindex"));
   num_styles = rows (styleorder);
-  if (style_idx > num_styles)
-    style_idx = mod (style_idx, num_styles);
-  endif
-  if (style_idx < 1)
+  style_idx = mod (style_idx, num_styles);
+  if (style_idx == 0)
+    style_idx = num_styles;
+  elseif (style_idx < 0)
     style_idx = 1;
   endif
 
@@ -62,13 +62,13 @@
 %!   set (hax, "colororder", [0 0 1]);
 %!   set (hax, "linestyleorder", {"-", ":", "--"});
 %!   hold on;
-%!   h = plot (1:5,1:5, 1:4,1:4, 1:3,1:3);
+%!   h = plot (1:2,1:2, 2:3,2:3, 3:4,3:4);
 %!   assert (get (h, "linestyle"), {"-"; ":"; "--"});
 %!   cla (hax);
 %!   hold on;
-%!   h1 = plot (1:5,1:5);
-%!   h2 = plot (1:4,1:4);
-%!   h3 = plot (1:3,1:3);
+%!   h1 = plot (1:2,1:2);
+%!   h2 = plot (2:3,2:3);
+%!   h3 = plot (3:4,3:4);
 %!   assert (get ([h1;h2;h3], "linestyle"), {"-"; ":"; "--"});
 %! unwind_protect_cleanup
 %!   close (hf);