# HG changeset patch # User Rik # Date 1467928990 25200 # Node ID 7ac3dd72fff92977730acc83e978625e5987014c # Parent 3008798dc5ba327e43b8edf576e0f98e7ec1b21e 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. diff -r 3008798dc5ba -r 7ac3dd72fff9 scripts/plot/util/__next_line_color__.m --- 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); diff -r 3008798dc5ba -r 7ac3dd72fff9 scripts/plot/util/__next_line_style__.m --- 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);