Mercurial > hg > octave-thorsten
changeset 11434:1f54ee6760b5
legend.m: Only one legend per axes (bug 32022)
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sun, 02 Jan 2011 21:11:24 -0500 |
parents | 9f4321024fbf |
children | 20f53b3a558f |
files | scripts/ChangeLog scripts/plot/legend.m |
diffstat | 2 files changed, 30 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2011-01-02 Ben Abbott <bpabbott@mac.com> + + * plot/legend.m: Only one legend per axes (bug 32022). Add / modify + demos to test addional features. + 2010-12-31 Rik <octave@nomad.inbox5.com> * general/is_duplicate_entry.m , general/isdir.m, general/isscalar.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