Mercurial > hg > octave-lojdl
changeset 12395:4d30b4136a3e
legend.m: Align legends to plot box, add demo. Bug 32373.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sun, 06 Feb 2011 16:45:05 -0500 |
parents | c2e1973d870b |
children | 6ba430a75553 |
files | scripts/ChangeLog scripts/plot/legend.m |
diffstat | 2 files changed, 33 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,5 +1,6 @@ 2011-02-06 Ben Abbott <bpabbott@mac.com> + * plot/legend.m: Align legends to plot box, add demo. Bug 32373. * plot/legend.m: "legend off" should delete the legend object. 2011-02-06 David Bateman <dbateman@free.fr>
--- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -600,33 +600,32 @@ case "northeast" if (outside) lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3), ... - ca_outpos(2) + ca_outpos(4) - lpos(4), lpos(3), lpos(4)]; - new_pos = [ca_pos(1), ca_pos(2), ca_pos(3) - lpos(3), ... - ca_pos(4) - lpos(4)]; + ca_pos(2) + ca_pos(4) - lpos(4), lpos(3), lpos(4)]; + new_pos = [ca_pos(1), ca_pos(2), ca_pos(3) - lpos(3), ca_pos(4)]; new_outpos = [ca_outpos(1), ca_outpos(2), ... - ca_outpos(3) - lpos(3), ca_outpos(4) - lpos(4)]; + ca_outpos(3) - lpos(3), ca_outpos(4)]; else lpos = [ca_pos(1) + ca_pos(3) - lpos(3) - ypad, ... ca_pos(2) + ca_pos(4) - lpos(4) - ypad, lpos(3), lpos(4)]; endif case "northwest" if (outside) - lpos = [ca_outpos(1), ca_outpos(2) + ca_outpos(4) - lpos(4), ... + lpos = [ca_outpos(1), ca_pos(2) + ca_pos(4) - lpos(4), ... lpos(3), lpos(4)]; new_pos = [ca_pos(1) + lpos(3), ca_pos(2), ... - ca_pos(3) - lpos(3), ca_pos(4) - lpos(4)]; + ca_pos(3) - lpos(3), ca_pos(4)]; new_outpos = [ca_outpos(1) + lpos(3), ca_outpos(2), ... - ca_outpos(3) - lpos(3), ca_outpos(4) - lpos(4)]; + ca_outpos(3) - lpos(3), ca_outpos(4)]; else lpos = [ca_pos(1) + ypad, ... ca_pos(2) + ca_pos(4) - lpos(4) - ypad, lpos(3), lpos(4)]; endif case "southeast" if (outside) - lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3), ca_outpos(2), ... + lpos = [ca_outpos(1) + ca_outpos(3) - lpos(3), ca_pos(2), ... lpos(3), lpos(4)]; - new_pos = [ca_pos(1), ca_pos(2) + lpos(4), ... - ca_pos(3) - lpos(3), ca_pos(4) - lpos(4)]; + new_pos = [ca_pos(1), ca_pos(2), ... + ca_pos(3) - lpos(3), ca_pos(4)]; new_outpos = [ca_outpos(1), ca_outpos(2) + lpos(4), ... ca_outpos(3) - lpos(3), ca_outpos(4) - lpos(4)]; else @@ -635,9 +634,9 @@ endif case "southwest" if (outside) - lpos = [ca_outpos(1), ca_outpos(2), 0, lpos(3), lpos(4)]; - new_pos = [ca_pos(1) +lpos(3), ca_pos(2) + lpos(4), ... - ca_pos(3) - lpos(3), ca_pos(4) - lpos(4)]; + lpos = [ca_outpos(1), ca_pos(2), lpos(3), lpos(4)]; + new_pos = [ca_pos(1) + lpos(3), ca_pos(2), ... + ca_pos(3) - lpos(3), ca_pos(4)]; new_outpos = [ca_outpos(1) + lpos(3), ca_outpos(2) + lpos(4), ... ca_outpos(3) - lpos(3), ca_outpos(4) - lpos(4)]; else @@ -1110,3 +1109,23 @@ %! legend off %! axis ([0, 10, 0 1]) +%!demo +%! clf +%! x = 0:4; +%! subplot (2, 2, 1) +%! plot (x, rand (numel (x))); +%! legend (cellstr (num2str ((1:10)')), "location", "northwestoutside") +%! legend boxon +%! subplot (2, 2, 2) +%! plot (x, rand (numel (x))); +%! legend (cellstr (num2str ((1:10)')), "location", "northeastoutside") +%! legend boxon +%! subplot (2, 2, 3); +%! plot (x, rand (numel (x))); +%! legend (cellstr (num2str ((1:10)')), "location", "southwestoutside") +%! legend boxon +%! subplot (2, 2, 4) +%! plot (x, rand (numel (x))); +%! legend (cellstr (num2str ((1:10)')), "location", "southeastoutside") +%! legend boxon +