# HG changeset patch # User John W. Eaton # Date 1204186030 18000 # Node ID b1ff001022af99d187832d01222c48c0b0a386dd # Parent 6acd0a18a3ee08cdc41b57cecd7e73c4ec4d33b4 __go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction diff -r 6acd0a18a3ee -r b1ff001022af scripts/ChangeLog --- a/scripts/ChangeLog Wed Feb 27 22:36:23 2008 +0100 +++ b/scripts/ChangeLog Thu Feb 28 03:07:10 2008 -0500 @@ -1,3 +1,13 @@ +2008-02-28 John W. Eaton + + * plot/__go_draw_axes__.m (get_old_gnuplot_color): New subfunction. + Use it to replace repeated if/elseif blocks. + +2008-02-28 Kai Habel + + * plot/__go_draw_axes__.m: If facecolor property of a surface is + "none", don't use pm3d mode and set linestyle correctly. + 2008-02-25 Ben Abbott * control/system/zpout.m, finance/irr.m, general/int2str.m, diff -r 6acd0a18a3ee -r b1ff001022af scripts/plot/__go_draw_axes__.m --- a/scripts/plot/__go_draw_axes__.m Wed Feb 27 22:36:23 2008 +0100 +++ b/scripts/plot/__go_draw_axes__.m Thu Feb 28 03:07:10 2008 -0500 @@ -603,25 +603,7 @@ withclause{data_idx} = sprintf ("with filledcurve %s", colorspec); else - if (isequal (color, [0,0,0])) - typ = -1; - elseif (isequal (color, [1,0,0])) - typ = 1; - elseif (isequal (color, [0,1,0])) - typ = 2; - elseif (isequal (color, [0,0,1])) - typ = 3; - elseif (isequal (color, [1,0,1])) - typ = 4; - elseif (isequal (color, [0,1,1])) - typ = 5; - elseif (isequal (color, [1,1,1])) - typ = -1; - elseif (isequal (color, [1,1,0])) - typ = 7; - else - typ = -1; - endif + typ = get_old_gnuplot_color (color); withclause{data_idx} = sprintf ("with filledcurve lt %d", typ); endif data{data_idx} = [xcol, ycol]'; @@ -793,25 +775,7 @@ style, lw, pt, lt, ps, colorspec); else - if (isequal (color, [0,0,0])) - typ = -1; - elseif (isequal (color, [1,0,0])) - typ = 1; - elseif (isequal (color, [0,1,0])) - typ = 2; - elseif (isequal (color, [0,0,1])) - typ = 3; - elseif (isequal (color, [1,0,1])) - typ = 4; - elseif (isequal (color, [0,1,1])) - typ = 5; - elseif (isequal (color, [1,1,1])) - typ = -1; - elseif (isequal (color, [1,1,0])) - typ = 7; - else - typ = -1; - endif + typ = get_old_gnuplot_color (color); withclause{data_idx} = sprintf ("with %s %s %s %s lt %d", style, lw, pt, ps, typ); endif @@ -940,25 +904,7 @@ "set style line %d %s lw %f;\n", data_idx, colorspec, obj.linewidth); else - if (isequal (edgecol, [0,0,0])) - typ = -1; - elseif (isequal (edgecol, [1,0,0])) - typ = 1; - elseif (isequal (edgecol, [0,1,0])) - typ = 2; - elseif (isequal (edgecol, [0,0,1])) - typ = 3; - elseif (isequal (edgecol, [1,0,1])) - typ = 4; - elseif (isequal (edgecol, [0,1,1])) - typ = 5; - elseif (isequal (edgecol, [1,1,1])) - typ = -1; - elseif (isequal (edgecol, [1,1,0])) - typ = 7; - else - typ = -1; - endif + typ = get_old_gnuplot_color (edgecol); fprintf (plot_stream, "set style line %d lt %d lw %f;\n", data_idx, typ, obj.linewidth); @@ -983,7 +929,7 @@ else edgecol = obj.edgecolor; if (ischar (obj.edgecolor)) - edgecol = [0,0,0]; + edgecol = [0, 0, 0]; endif fprintf (plot_stream, "set pm3d explicit at s hidden3d %d %s %s corners2color c3;\n", data_idx, interp_str, dord); @@ -999,25 +945,7 @@ "set style line %d %s lw %f;\n", data_idx, colorspec, obj.linewidth); else - if (isequal (edgecol, [0,0,0])) - typ = -1; - elseif (isequal (edgecol, [1,0,0])) - typ = 1; - elseif (isequal (edgecol, [0,1,0])) - typ = 2; - elseif (isequal (edgecol, [0,0,1])) - typ = 3; - elseif (isequal (edgecol, [1,0,1])) - typ = 4; - elseif (isequal (edgecol, [0,1,1])) - typ = 5; - elseif (isequal (edgecol, [1,1,1])) - typ = -1; - elseif (isequal (edgecol, [1,1,0])) - typ = 7; - else - typ = -1; - endif + typ = get_old_gnuplot_color (edgecol); fprintf (plot_stream, "set style line %d lt %d lw %f;\n", data_idx, typ, obj.linewidth); @@ -1335,25 +1263,7 @@ round (255*color)); endif else - if (isequal (color, [0,0,0])) - typ = -1; - elseif (isequal (color, [1,0,0])) - typ = 1; - elseif (isequal (color, [0,1,0])) - typ = 2; - elseif (isequal (color, [0,0,1])) - typ = 3; - elseif (isequal (color, [1,0,1])) - typ = 4; - elseif (isequal (color, [0,1,1])) - typ = 5; - elseif (isequal (color, [1,1,1])) - typ = 6; - elseif (isequal (color, [1,1,0])) - typ = 7; - else - typ = 2; - endif + typ = get_old_gnuplot_color (color); endif endif found_style = true; @@ -1657,25 +1567,7 @@ round (255*color)); endif else - if (isequal (color, [0,0,0])) - typ = -1; - elseif (isequal (color, [1,0,0])) - typ = 1; - elseif (isequal (color, [0,1,0])) - typ = 2; - elseif (isequal (color, [0,0,1])) - typ = 3; - elseif (isequal (color, [1,0,1])) - typ = 4; - elseif (isequal (color, [0,1,1])) - typ = 5; - elseif (isequal (color, [1,1,1])) - typ = -1; - elseif (isequal (color, [1,1,0])) - typ = 7; - else - typ = -1; - endif + typ = get_old_gnuplot_color (color); colorspec = sprintf ("textcolor lt %d", typ); endif endfunction @@ -2114,3 +2006,25 @@ endif endif endfunction + +function typ = get_old_gnuplot_color (color) + if (isequal (color, [0, 0, 0])) + typ = -1; + elseif (isequal (color, [1, 0, 0])) + typ = 1; + elseif (isequal (color, [0, 1, 0])) + typ = 2; + elseif (isequal (color, [0, 0, 1])) + typ = 3; + elseif (isequal (color, [1, 0, 1])) + typ = 4; + elseif (isequal (color, [0, 1, 1])) + typ = 5; + elseif (isequal (color, [1, 1, 1])) + typ = -1; + elseif (isequal (color, [1, 1, 0])) + typ = 7; + else + typ = -1; + endif +endfunction