# HG changeset patch # User Ben Abbott # Date 1294020684 18000 # Node ID 1f54ee6760b55058a568792bde8e2337838abca3 # Parent 9f4321024fbf73f294e3e2f27dd52bfd119c4239 legend.m: Only one legend per axes (bug 32022) diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2011-01-02 Ben Abbott + + * plot/legend.m: Only one legend per axes (bug 32022). Add / modify + demos to test addional features. + 2010-12-31 Rik * general/is_duplicate_entry.m , general/isdir.m, general/isscalar.m, diff --git a/scripts/plot/legend.m b/scripts/plot/legend.m --- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -466,6 +466,7 @@ axes (hlegend); delete (get (hlegend, "children")); endif + ## Add text label to the axis first, checking their extents nentries = numel (hplots); texthandle = []; @@ -774,8 +775,9 @@ persistent recursive = false; if (! recursive) recursive = true; + hax = getfield (get (h, "userdata"), "handle"); [hplots, text_strings] = getlegenddata (h); - h = legend (fliplr (hplots), get (h, "string")); + h = legend (hax, flipud (hplots), get (h, "string")); recursive = false; endif endfunction @@ -987,20 +989,37 @@ %!demo %! clf %! x = 0:1; -%! plot (x, x, ";1;", x, 2*x, x, 3*x, ";3;") -%! title ("1 is Blue, and 3 is Red") +%! plot (x, x, ";I am Blue;", x, 2*x, x, 3*x, ";I am Red;") %!demo %! clf %! plot(1:10, 1:10, 1:10, fliplr(1:10)); %! title("incline is blue and decline is green"); -%! legend({"I'm blue", "I'm green"}, "location", "east"); +%! legend({"I am blue", "I am green"}, "location", "east"); +%! legend({"I am blue", "I am green"}, "location", "east"); +%! legend hide +%! legend show %!demo %! clf %! plot(1:10, 1:10, 1:10, fliplr(1:10)); -%! title("incline is blue and decline is green"); -%! legend("I'm blue", "I'm green", "location", "east"); +%! title("Legend is hidden") +%! legend({"I am blue", "I am green"}, "location", "east"); +%! legend hide + +%!demo +%! clf +%! plot(1:10, 1:10, 1:10, fliplr(1:10)); +%! title("Legend with box on") +%! legend({"I am blue", "I am green"}, "location", "east"); +%! legend boxon + +%!demo +%! clf +%! plot(1:10, 1:10, 1:10, fliplr(1:10)); +%! title("Legend with text to the right") +%! legend({"I am blue", "I am green"}, "location", "east"); +%! legend right %!demo %! clf