Mercurial > hg > octave-shane
changeset 11684:e77150aa1ac2 release-3-0-x
__go_draw_axes__: eliminate repeated code with get_old_gnuplot_color subfunction
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 11 Mar 2008 22:07:27 -0400 |
parents | 738ca2f7c83e |
children | 61244c9d99b3 |
files | scripts/ChangeLog scripts/plot/__go_draw_axes__.m |
diffstat | 2 files changed, 38 insertions(+), 96 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,13 @@ +2008-03-11 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-03-11 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-03-07 John W. Eaton <jwe@octave.org> * plot/contourf.m: Set axes layer property to "top".
--- 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]'; @@ -782,25 +764,7 @@ withclause{data_idx} = sprintf ("with %s %s %s %s %s", style, 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 lt %d", style, pt, ps, typ); endif @@ -933,7 +897,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); @@ -949,25 +913,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); @@ -1285,25 +1231,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; @@ -1607,25 +1535,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 @@ -2064,3 +1974,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