Mercurial > hg > octave-nkf
diff scripts/plot/__go_draw_axes__.m @ 6885:987a7bf45c99
[project @ 2007-09-10 20:51:09 by jwe]
author | jwe |
---|---|
date | Mon, 10 Sep 2007 20:51:09 +0000 |
parents | 32558239ed9e |
children | 76e3d985ae56 |
line wrap: on
line diff
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -427,53 +427,72 @@ endif case "patch" - if (! have_newer_gnuplot) - warning ("patch objects require gnuplot v4.2 or later!, sorry") + if (! isempty (obj.zdata)) + warning ("gnuplot (as of v4.2) supports only 2D patches, ignoring z values") + endif + nd = 2; + cmap = parent_figure_obj.colormap; + clim = axis_obj.clim; + data_idx++; + is_image_data(data_idx) = false; + parametric(data_idx) = false; + titlespec{data_idx} = "title \"\""; + usingclause{data_idx} = ""; + if (isfield (obj, "facecolor") && isfield (obj, "cdata")) + if (strncmp (obj.facecolor, "none", 4)) + color = [1, 1, 1]; + elseif (strncmp (obj.facecolor, "flat", 4)) + r = 1 + round ((size (cmap, 1) - 1) * (obj.cdata - clim(1))/(clim(2) - clim(1))); + r = max (1, min (r, size (cmap, 1))); + color = cmap(r,:); + elseif (strncmp (obj.facecolor, "interp", 6)) + warning ("\"interp\" not supported, using 1st entry of cdata") + r = 1 + round ((size (cmap, 1) - 1) * obj.cdata(1)); + r = max (1, min (r, size (cmap, 1))); + color = cmap(r,:); + else + color = obj.facecolor; + endif else - if (! isempty (obj.zdata)) - warning ("gnuplot (as of v4.2) supports only 2D patches, ignoring z values") + color = [1, 0, 0]; + endif + + if (have_newer_gnuplot) + withclause{data_idx} = sprintf ("with filledcurve lc rgb \"#%02x%02x%02x\"",round (255*color)); + 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 - nd = 2; - cmap = parent_figure_obj.colormap; - clim = axis_obj.clim; - data_idx++; - is_image_data(data_idx) = false; - parametric(data_idx) = false; - titlespec{data_idx} = "title \"\""; - usingclause{data_idx} = ""; - if (isfield (obj, "facecolor") && isfield (obj, "cdata")) - if (strncmp (obj.facecolor, "none", 4)) - color = [1, 1, 1]; - elseif (strncmp (obj.facecolor, "flat", 4)) - r = 1 + round ((size (cmap, 1) - 1) * (obj.cdata - clim(1))/(clim(2) - clim(1))); - r = max (1, min (r, size (cmap, 1))); - color = cmap(r,:); - elseif (strncmp (obj.facecolor, "interp", 6)) - warning ("\"interp\" not supported, using 1st entry of cdata") - r = 1 + round ((size (cmap, 1) - 1) * obj.cdata(1)); - r = max (1, min (r, size (cmap, 1))); - color = cmap(r,:); - else - color = obj.facecolor; - endif - else - color = [1, 0, 0]; - endif + withclause{data_idx} = sprintf ("with filledcurve lt %d", typ); + endif + + xdat = obj.xdata(:); + ydat = obj.ydata(:); - withclause{data_idx} = sprintf ("with filledcurve lc rgb \"#%02x%02x%02x\"",round (255*color)); - - xdat = obj.xdata(:); - ydat = obj.ydata(:); - - if (xautoscale) - [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat); - endif - if (yautoscale) - [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ydat); - endif - data{data_idx} = [xdat, ydat]'; - usingclause{data_idx} = "using ($1):($2)"; + if (xautoscale) + [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat); endif + if (yautoscale) + [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ydat); + endif + data{data_idx} = [xdat, ydat]'; + usingclause{data_idx} = "using ($1):($2)"; ## patch outline data_idx++; @@ -496,7 +515,30 @@ else color = [0, 0, 0]; endif - withclause{data_idx} = sprintf ("with lines lc rgb \"#%02x%02x%02x\"",round (255*color)); + if (have_newer_gnuplot) + withclause{data_idx} = sprintf ("with lines lc rgb \"#%02x%02x%02x\"",round (255*color)); + 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 + withclause{data_idx} = sprintf ("with lines lt %d", typ); + endif xdat = [xdat; xdat(1)]; ydat = [ydat; ydat(1)];