changeset 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 6b7e9724912a
files scripts/plot/legend.m
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/legend.m	Tue May 01 19:38:51 2012 -0400
+++ b/scripts/plot/legend.m	Wed May 02 21:14:40 2012 -0400
@@ -272,6 +272,9 @@
     else
       error ("legend: expecting argument to be a character string");
     endif
+  elseif (nargs > 1 && iscellstr (varargin{1}))
+    varargin = {varargin{1}{:}, varargin{2:end}};
+    nargs = numel (varargin);
   endif
 
   if (strcmp (show, "off"))
@@ -969,6 +972,11 @@
 endfunction
 
 %!demo
+%! plot (rand (2))
+%! legend ({'foo'}, 'bar', 'boxoff')
+%! title ('legend() should warn about an extra label')
+
+%!demo
 %! plot (rand (2,2)) ;
 %! h = legend ('a', 'b') ;
 %! legend ('right') ;