Mercurial > hg > octave-lyh
changeset 12402:766426578c14 release-3-4-x
legend.m: "legend off" should delete the legend object.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sun, 06 Feb 2011 15:32:38 -0500 |
parents | 88e8779f525e |
children | 581f65bcc1a4 |
files | scripts/ChangeLog scripts/plot/legend.m |
diffstat | 2 files changed, 24 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2011-02-06 Ben Abbott <bpabbott@mac.com> + + * plot/legend.m: "legend off" should delete the legend object. + 2011-02-06 David Bateman <dbateman@free.fr> * plot/legend.m : Delete old legend before probing the position and outerposition. Reshape lpos correct if the legend locqtion is
--- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -81,9 +81,11 @@ ## Show legend on the plot ## ## @item "hide" -## @itemx "off" ## Hide legend on the plot ## +## @itemx "toggle" +## Toggles between "hide" and "show" +## ## @item "boxon" ## Show a box around legend ## @@ -95,6 +97,9 @@ ## ## @item "right" ## Place text to the right of the keys +## +## @itemx "off" +## Delete the legend object ## @end table ## @end deftypefn @@ -217,7 +222,10 @@ if (rows (arg) == 1) str = tolower (deblank (arg)); switch (str) - case {"off", "hide"} + case {"off"} + delete (hlegend); + return + case {"hide"} show = "off"; nargs--; case "show" @@ -1091,4 +1099,14 @@ %! hold off %! legend ({"sin(x)", "cos(x)"}, "location", "northeastoutside") +%!demo +%! clf +%! x = 0:10; +%! plot (x, rand (11)); +%! xlabel ("Indices") +%! ylabel ("Random Values") +%! title ("Legend ""off"" should delete the legend") +%! legend (cellstr (num2str ((1:10)')), "location", "northeastoutside") +%! legend off +%! axis ([0, 10, 0 1])