comparison scripts/plot/legend.m @ 14589:fd6e50e2eee6

legend() should accept labels being specified as both cellstrs and char. legend.m: Accept labels as both cell strings and character strings.
author Ben Abbott <bpabbott@mac.com>
date Wed, 02 May 2012 21:14:40 -0400
parents c38a253723d3
children 3ddb62bd67c5
comparison
equal deleted inserted replaced
14585:c38a253723d3 14589:fd6e50e2eee6
270 varargin = arg; 270 varargin = arg;
271 nargs = numel (varargin); 271 nargs = numel (varargin);
272 else 272 else
273 error ("legend: expecting argument to be a character string"); 273 error ("legend: expecting argument to be a character string");
274 endif 274 endif
275 elseif (nargs > 1 && iscellstr (varargin{1}))
276 varargin = {varargin{1}{:}, varargin{2:end}};
277 nargs = numel (varargin);
275 endif 278 endif
276 279
277 if (strcmp (show, "off")) 280 if (strcmp (show, "off"))
278 if (! isempty (hlegend)) 281 if (! isempty (hlegend))
279 set (findobj (hlegend), "visible", "off"); 282 set (findobj (hlegend), "visible", "off");
967 endif 970 endif
968 endif 971 endif
969 endfunction 972 endfunction
970 973
971 %!demo 974 %!demo
975 %! plot (rand (2))
976 %! legend ({'foo'}, 'bar', 'boxoff')
977 %! title ('legend() should warn about an extra label')
978
979 %!demo
972 %! plot (rand (2,2)) ; 980 %! plot (rand (2,2)) ;
973 %! h = legend ('a', 'b') ; 981 %! h = legend ('a', 'b') ;
974 %! legend ('right') ; 982 %! legend ('right') ;
975 %! set (h, 'textposition', 'left') 983 %! set (h, 'textposition', 'left')
976 %! set (h, 'textposition', 'right') 984 %! set (h, 'textposition', 'right')