Mercurial > hg > octave-kai
changeset 7542:b1ff001022af
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 28 Feb 2008 03:07:10 -0500 |
parents | 6acd0a18a3ee |
children | b84c5cbc0812 |
files | scripts/ChangeLog scripts/plot/__go_draw_axes__.m |
diffstat | 2 files changed, 39 insertions(+), 115 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,13 @@ +2008-02-28 John W. Eaton <jwe@octave.org> + + * plot/__go_draw_axes__.m (get_old_gnuplot_color): New subfunction. + Use it to replace repeated if/elseif blocks. + +2008-02-28 Kai Habel <kai.habel@gmx.de> + + * 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 <bpabbott@mac.com> * control/system/zpout.m, finance/irr.m, general/int2str.m,
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -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