Mercurial > hg > octave-nkf
diff scripts/plot/legend.m @ 8208:f6ca8ff51818
[mq]: graphics-backend
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 10 Oct 2008 11:07:53 -0400 |
parents | 73d6b71788c0 |
children | 79c874fe5100 |
line wrap: on
line diff
--- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -80,10 +80,9 @@ function legend (varargin) + [ca, varargin, nargin] = __plt_get_axis_arg__ ("legend", varargin{:}); nargs = nargin; - ca = gca (); - if (nargs > 0) pos = varargin{nargs}; if (isnumeric (pos) && isscalar (pos) && round (pos) == pos) @@ -132,12 +131,25 @@ case "boxoff" set (ca, "keybox", "off"); otherwise - while (k <= nkids && ! strcmp (get (kids(k), "type"), "line")) + typ = get (kids (k), "type"); + while (k <= nkids && ! strcmp (typ, "line") && + ! strcmp (typ, "hggroup")) k++; endwhile if (k <= nkids) turn_on_legend = true; - set (kids(k), "keylabel", arg); + if (strcmp (typ, "hggroup")) + hgkids = get (kids(k), "children"); + for j = 1 : length (hgkids) + hgobj = get (hgkids (j)); + if (isfield (hgobj, "keylabel")) + set (hgkids(j), "keylabel", arg); + break; + endif + endfor + else + set (kids(k), "keylabel", arg); + endif else warning ("legend: ignoring extra labels"); endif @@ -160,7 +172,8 @@ for i = 1:nkids if (strcmp (get (kids(k), "type"), "line") || strcmp (get (kids(k), "type"), "surface") - || strcmp (get (kids(k), "type"), "patch")) + || strcmp (get (kids(k), "type"), "patch") + || strcmp (get (kids(k), "type"), "hggroup")) have_data = true; break; endif @@ -177,11 +190,23 @@ while (k <= nkids && ! (strcmp (get (kids(k), "type"), "line") || strcmp (get (kids(k), "type"), "surface") - || strcmp (get (kids(k), "type"), "patch"))) + || strcmp (get (kids(k), "type"), "patch") + || strcmp (get (kids(k), "type"), "hggroup"))) k++; endwhile if (k <= nkids) - set (kids(k), "keylabel", arg); + if (strcmp (get (kids(k), "type"), "hggroup")) + hgkids = get (kids(k), "children"); + for j = 1 : length (hgkids) + hgobj = get (hgkids (j)); + if (isfield (hgobj, "keylabel")) + set (hgkids(j), "keylabel", arg); + break; + endif + endfor + else + set (kids(k), "keylabel", arg); + endif turn_on_legend = true; k++; elseif (! warned) @@ -189,6 +214,9 @@ warning ("legend: ignoring extra labels"); endif else + arg + get(kids(k),"type") + k error ("legend: expecting argument to be a character string"); endif endfor