Legend labels order

Ben Abbott bpabbott at mac.com
Thu Jul 23 09:56:31 CDT 2009


On Thursday, July 23, 2009, at 10:27AM, "John W. Eaton" <jwe at octave.org> wrote:
>On 22-Jul-2009, Marco Caliari wrote:
>
>| I discovered the following problem in 3.2.x. When you have two plots but 
>| only one legend label, such as in
>| 
>| x=linspace(0,10);,plot(x,x,x,x.^2),legend('linear')
>| 
>| the label is attached to the second plot. Similar behavior in the case
>| 
>| x=linspace(0,10);,plot(x,x,x,x.^2,x,x.^3),legend('linear','quadratic')
>| 
>| or
>| 
>| x=linspace(0,10);,plot(x,x),hold on,plot(x,x.^2,'g'),legend('linear')
>| 
>| I'm able to fix this problem if I substitute
>| 
>| set (kids(k), "keylabel", arg);
>| 
>| with
>| 
>| set (kids(nkids-nargs+k), "keylabel", arg);
>| 
>| in legend.m (two occourences). But, since there is a similar code some 
>| rows above regarding hggroup (and I don't know what a hggroup is), I 
>| cannot submit a complete patch. I hope somebody else can fix it.
>
>The hggroup object is used for things like stem plots.
>
>I checked in the following change
>
>  http://hg.savannah.gnu.org/hgweb/octave/rev/350148cc0774
>
>It seems to work corrctly for me.
>
>Could you please try it with 3.2.x and let us know if you see
>problems?  If it works, then I suppose it would be OK to include with
>a future 3.2.x release.
>
>jwe

Nice. This is much easier to follow.

Shall a demo be included for hggroups as well?

%!demo
%! clf
%! bar (rand (2, 3))
%! ylim ([0 1.2])
%! legend ({"1st Bar", "2nd Bar", "3rd Bar"})

Ben



More information about the Bug-octave mailing list