# HG changeset patch # User Ben Abbott # Date 1297024358 18000 # Node ID 766426578c1493e2cebc76de0360a8335747a1c3 # Parent 88e8779f525eebbdd3f063fd786d064daf94ef77 legend.m: "legend off" should delete the legend object. diff -r 88e8779f525e -r 766426578c14 scripts/ChangeLog --- a/scripts/ChangeLog Sun Feb 06 17:17:12 2011 +0100 +++ b/scripts/ChangeLog Sun Feb 06 15:32:38 2011 -0500 @@ -1,3 +1,7 @@ +2011-02-06 Ben Abbott + + * plot/legend.m: "legend off" should delete the legend object. + 2011-02-06 David Bateman * plot/legend.m : Delete old legend before probing the position and outerposition. Reshape lpos correct if the legend locqtion is diff -r 88e8779f525e -r 766426578c14 scripts/plot/legend.m --- a/scripts/plot/legend.m Sun Feb 06 17:17:12 2011 +0100 +++ b/scripts/plot/legend.m Sun Feb 06 15:32:38 2011 -0500 @@ -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])