Mercurial > octave-nkf
comparison scripts/plot/legend.m @ 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 | f16a5244d93a |
children | 4d30b4136a3e |
comparison
equal
deleted
inserted
replaced
12401:88e8779f525e | 12402:766426578c14 |
---|---|
79 ## @table @asis | 79 ## @table @asis |
80 ## @item "show" | 80 ## @item "show" |
81 ## Show legend on the plot | 81 ## Show legend on the plot |
82 ## | 82 ## |
83 ## @item "hide" | 83 ## @item "hide" |
84 ## @itemx "off" | |
85 ## Hide legend on the plot | 84 ## Hide legend on the plot |
85 ## | |
86 ## @itemx "toggle" | |
87 ## Toggles between "hide" and "show" | |
86 ## | 88 ## |
87 ## @item "boxon" | 89 ## @item "boxon" |
88 ## Show a box around legend | 90 ## Show a box around legend |
89 ## | 91 ## |
90 ## @item "boxoff" | 92 ## @item "boxoff" |
93 ## @item "left" | 95 ## @item "left" |
94 ## Place text to the left of the keys | 96 ## Place text to the left of the keys |
95 ## | 97 ## |
96 ## @item "right" | 98 ## @item "right" |
97 ## Place text to the right of the keys | 99 ## Place text to the right of the keys |
100 ## | |
101 ## @itemx "off" | |
102 ## Delete the legend object | |
98 ## @end table | 103 ## @end table |
99 ## @end deftypefn | 104 ## @end deftypefn |
100 | 105 |
101 function [hlegend2, hobjects2, hplot2, text_strings2] = legend (varargin) | 106 function [hlegend2, hobjects2, hplot2, text_strings2] = legend (varargin) |
102 | 107 |
215 arg = varargin{1}; | 220 arg = varargin{1}; |
216 if (ischar (arg)) | 221 if (ischar (arg)) |
217 if (rows (arg) == 1) | 222 if (rows (arg) == 1) |
218 str = tolower (deblank (arg)); | 223 str = tolower (deblank (arg)); |
219 switch (str) | 224 switch (str) |
220 case {"off", "hide"} | 225 case {"off"} |
226 delete (hlegend); | |
227 return | |
228 case {"hide"} | |
221 show = "off"; | 229 show = "off"; |
222 nargs--; | 230 nargs--; |
223 case "show" | 231 case "show" |
224 show = "on"; | 232 show = "on"; |
225 nargs--; | 233 nargs--; |
1089 %! hold all | 1097 %! hold all |
1090 %! plot (x, cos(x), ";cos(x);") | 1098 %! plot (x, cos(x), ";cos(x);") |
1091 %! hold off | 1099 %! hold off |
1092 %! legend ({"sin(x)", "cos(x)"}, "location", "northeastoutside") | 1100 %! legend ({"sin(x)", "cos(x)"}, "location", "northeastoutside") |
1093 | 1101 |
1094 | 1102 %!demo |
1103 %! clf | |
1104 %! x = 0:10; | |
1105 %! plot (x, rand (11)); | |
1106 %! xlabel ("Indices") | |
1107 %! ylabel ("Random Values") | |
1108 %! title ("Legend ""off"" should delete the legend") | |
1109 %! legend (cellstr (num2str ((1:10)')), "location", "northeastoutside") | |
1110 %! legend off | |
1111 %! axis ([0, 10, 0 1]) | |
1112 |