Mercurial > hg > octave-avbm
changeset 7148:735086cfd405
[project @ 2007-11-09 18:01:44 by jwe]
author | jwe |
---|---|
date | Fri, 09 Nov 2007 18:01:45 +0000 |
parents | fdb3840cec66 |
children | 5c121a8b40b5 |
files | scripts/ChangeLog scripts/plot/__bar__.m scripts/plot/__go_draw_axes__.m scripts/plot/legend.m src/ChangeLog src/graphics.cc src/graphics.h.in |
diffstat | 7 files changed, 61 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -9,6 +9,12 @@ 2007-11-09 David Bateman <dbateman@free.fr> + * plot/legend.m: Also allow labels for surface and patch types. + * plot/__bar__.m: Split into separate patch pbjects to allow + setting of the legend. + * plot/__go_draw_axes__.m: Set titlespec from keylabel for patch + objects as well. + * plot/area.m, plot/__area__.m: New functions * plot/Makefile.in (SOURCES): Add them to the list of files.
--- a/scripts/plot/__bar__.m +++ b/scripts/plot/__bar__.m @@ -22,7 +22,8 @@ function varargout = __bar__ (vertical, func, varargin) - width = 0.8; + ## Slightly smaller than 0.8 to avoid clipping issue in gnuplot 4.0 + width = 0.8 - 10 * eps; group = true; if (nargin < 3) @@ -133,33 +134,42 @@ yb(3:4:4*ylen,:) = y1; yb(4:4:4*ylen,:) = y0; - xb = reshape (xb, 4, numel (xb) / 4); - yb = reshape (yb, 4, numel (yb) / 4); + xb = reshape (xb, [4, numel(xb) / 4 / ycols, ycols]); + yb = reshape (yb, [4, numel(yb) / 4 / ycols, ycols]); - if (! have_line_spec) - colors = [1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1]; - newargs = [{shiftdim(colors (mod (floor ([0 : (ycols * ylen - 1)] / ylen), - 6) + 1, :), -1)}, newargs]; - endif - + color = [1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1]; if (vertical) - if (nargout < 1) + if (nargout < 2) newplot (); - patch (xb, yb, newargs {:}); - elseif (nargout < 2) - newplot (); - varargout{1} = patch (xb, yb, newargs {:}); + tmp = []; + for i = 1 : ycols + if (! have_line_spec) + tmp = [tmp; patch(xb(:,:,i), yb(:,:,i), color(i,:), newargs {:})]; + else + tmp = [tmp; patch(xb(:,:,i), yb(:,:,i), newargs {:})]; + endif + endfor + if (nargout == 1) + varargout{1} = tmp; + endif else varargout{1} = xb; varargout{2} = yb; endif else - if (nargout < 1) + if (nargout < 2) newplot (); - patch (yb, xb, newargs{:}); - elseif (nargout < 2) - newplot (); - varargout{1} = patch (yb, xb, newargs{:}); + tmp = []; + for i = 1 : ycols + if (! have_line_spec) + tmp = [tmp; patch(yb(:,:,i), xb(:,:,i), color(i,:), newargs {:})]; + else + tmp = [tmp; patch(yb(:,:,i), xb(:,:,i), newargs {:})]; + endif + endfor + if (nargout == 1) + varargout{1} = tmp; + endif else varargout{1} = yb; varargout{2} = xb;
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -456,7 +456,12 @@ is_image_data(data_idx) = false; parametric(data_idx) = false; have_cdata(data_idx) = false; - titlespec{data_idx} = "title \"\""; + if (i > 1 || isempty (obj.keylabel)) + titlespec{data_idx} = "title \"\""; + else + tmp = undo_string_escapes (obj.keylabel); + titlespec{data_idx} = strcat ("title \"", tmp, "\""); + endif usingclause{data_idx} = ""; if (isfield (obj, "facecolor") && isfield (obj, "cdata")) if (strncmp (obj.facecolor, "none", 4))
--- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -59,11 +59,11 @@ ## ## Some specific functions are directly available using @var{func}: ## -## @table @code +## @table @asis ## @item "show" ## Show legends from the plot ## @item "hide" -## @itemx off +## @itemx "off" ## Hide legends from the plot ## @item "boxon" ## Draw a box around legends @@ -158,7 +158,9 @@ if (nargs > 0) have_data = false; for i = 1:nkids - if (strcmp (get (kids(k), "type"), "line")) + if (strcmp (get (kids(k), "type"), "line") + || strcmp (get (kids(k), "type"), "surface") + || strcmp (get (kids(k), "type"), "patch")) have_data = true; break; endif @@ -172,7 +174,10 @@ for i = 1:nargs arg = varargin{i}; if (ischar (arg)) - while (k <= nkids && ! strcmp (get (kids(k), "type"), "line")) + while (k <= nkids + && ! (strcmp (get (kids(k), "type"), "line") + || strcmp (get (kids(k), "type"), "surface") + || strcmp (get (kids(k), "type"), "patch"))) k++; endwhile if (k <= nkids)
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2007-11-09 David Bateman <dbateman@free.fr> + * graphics.cc, graphics.h.in (class patch): Add the field "keylabel". + * data.cc (Fcputime) [__WIN32__]: Correct scaling of sys and usr times. * graphics.cc (is_handle): Handle must be a real scalar.
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -2138,7 +2138,8 @@ marker ("none"), markeredgecolor ("auto"), markerfacecolor ("none"), - markersize (1) + markersize (1), + keylabel ("") { } void @@ -2186,6 +2187,8 @@ set_markerfacecolor (val); else if (name.compare ("markersize")) set_markersize (val); + else if (name.compare ("keylabel")) + set_keylabel (val); else { modified = false; @@ -2220,6 +2223,7 @@ m.assign ("markeredgecolor", markeredgecolor); m.assign ("markerface", markerfacecolor); m.assign ("markersize", markersize); + m.assign ("keylabel", keylabel); return m; } @@ -2267,6 +2271,8 @@ retval = markerfacecolor; else if (name.compare ("markersize")) retval = markersize; + else if (name.compare ("keylabel")) + retval = keylabel; else warning ("get: invalid property `%s'", name.c_str ()); @@ -2293,7 +2299,7 @@ m["markeredgecolor"] = "auto"; m["markerfacecolor"] = "none"; m["markersize"] = 1; - + m["keylabel"] = ""; return m; }