# HG changeset patch # User Rik # Date 1277407347 25200 # Node ID 390d93e205319bb9d8e52379093b97aaabf5825a # Parent 172253d75d9413e77980d84d34030263927b0ebf Plot commands now print usage information without errors when called with no arguments (bug #29986). diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2010-06-24 John W. Eaton + + * plot/private/__plt__.m: Replace usage message with error. + * plot/loglog.m, plot/plot.m, plot/polar.m, plot/semilogx.m, + plot/semilogy.m: Call print_usage if no args are supplied. + Add additional calling forms to documentation. + 2010-06-24 Shai Ayal * plot/print.m: convert to wrapper for backend specific print functions diff --git a/scripts/plot/loglog.m b/scripts/plot/loglog.m --- a/scripts/plot/loglog.m +++ b/scripts/plot/loglog.m @@ -18,9 +18,14 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} loglog (@var{args}) +## @deftypefn {Function File} {} loglog (@var{y}) +## @deftypefnx {Function File} {} loglog (@var{x}, @var{y}) +## @deftypefnx {Function File} {} loglog (@var{x}, @var{y}, @var{property}, @var{value}, @dots{}) +## @deftypefnx {Function File} {} loglog (@var{x}, @var{y}, @var{fmt}) +## @deftypefnx {Function File} {} loglog (@var{h}, @dots{}) +## @deftypefnx {Function File} {@var{h} =} loglog (@dots{}) ## Produce a two-dimensional plot using log scales for both axes. See -## the description of @code{plot} for a description of the arguments +## the documentation of @code{plot} for a description of the arguments ## that @code{loglog} will accept. ## @seealso{plot, semilogx, semilogy} ## @end deftypefn @@ -29,7 +34,11 @@ function retval = loglog (varargin) - [h, varargin] = __plt_get_axis_arg__ ("loglog", varargin{:}); + [h, varargin, nargs] = __plt_get_axis_arg__ ("loglog", varargin{:}); + + if (nargs < 1) + print_usage(); + endif oldh = gca (); unwind_protect diff --git a/scripts/plot/plot.m b/scripts/plot/plot.m --- a/scripts/plot/plot.m +++ b/scripts/plot/plot.m @@ -179,7 +179,11 @@ function retval = plot (varargin) - [h, varargin] = __plt_get_axis_arg__ ("plot", varargin{:}); + [h, varargin, nargs] = __plt_get_axis_arg__ ("plot", varargin{:}); + + if (nargs < 1) + print_usage(); + endif oldh = gca (); unwind_protect diff --git a/scripts/plot/polar.m b/scripts/plot/polar.m --- a/scripts/plot/polar.m +++ b/scripts/plot/polar.m @@ -18,7 +18,10 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} polar (@var{theta}, @var{rho}, @var{fmt}) +## @deftypefn {Function File} {} polar (@var{theta}, @var{rho}) +## @deftypefnx {Function File} {} polar (@var{theta}, @var{rho}, @var{fmt}) +## @deftypefnx {Function File} {} polar (@var{h}, @dots{}) +## @deftypefnx {Function File} {@var{h} =} polar (@dots{}) ## Make a two-dimensional plot given the polar coordinates @var{theta} and ## @var{rho}. ## @@ -32,6 +35,10 @@ [h, varargin, nargs] = __plt_get_axis_arg__ ("polar", varargin{:}); + if (nargs < 1) + print_usage(); + endif + oldh = gca (); unwind_protect axes (h); diff --git a/scripts/plot/private/__plt__.m b/scripts/plot/private/__plt__.m --- a/scripts/plot/private/__plt__.m +++ b/scripts/plot/private/__plt__.m @@ -109,11 +109,7 @@ endwhile else - msg = sprintf ("%s (y)\n", caller); - msg = sprintf ("%s %s (x, y, ...)\n", msg, caller); - msg = sprintf ("%s %s (x, y, fmt, ...)\n", msg, caller); - msg = sprintf ("%s %s (x, y, property, value, ...)", msg, caller); - usage (msg); + error ("__plt__: invalid number of arguments"); endif endfunction diff --git a/scripts/plot/semilogx.m b/scripts/plot/semilogx.m --- a/scripts/plot/semilogx.m +++ b/scripts/plot/semilogx.m @@ -18,9 +18,14 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} semilogx (@var{args}) +## @deftypefn {Function File} {} semilogx (@var{y}) +## @deftypefnx {Function File} {} semilogx (@var{x}, @var{y}) +## @deftypefnx {Function File} {} semilogx (@var{x}, @var{y}, @var{property}, @var{value}, @dots{}) +## @deftypefnx {Function File} {} semilogx (@var{x}, @var{y}, @var{fmt}) +## @deftypefnx {Function File} {} semilogx (@var{h}, @dots{}) +## @deftypefnx {Function File} {@var{h} =} semilogx (@dots{}) ## Produce a two-dimensional plot using a logarithmic scale for the @var{x} -## axis. See the description of @code{plot} for a description of the +## axis. See the documentation of @code{plot} for a description of the ## arguments that @code{semilogx} will accept. ## @seealso{plot, semilogy, loglog} ## @end deftypefn @@ -29,7 +34,11 @@ function retval = semilogx (varargin) - [h, varargin] = __plt_get_axis_arg__ ("semilogx", varargin{:}); + [h, varargin, nargs] = __plt_get_axis_arg__ ("semilogx", varargin{:}); + + if (nargs < 1) + print_usage(); + endif oldh = gca (); unwind_protect diff --git a/scripts/plot/semilogy.m b/scripts/plot/semilogy.m --- a/scripts/plot/semilogy.m +++ b/scripts/plot/semilogy.m @@ -18,9 +18,14 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} semilogy (@var{args}) +## @deftypefn {Function File} {} semilogy (@var{y}) +## @deftypefnx {Function File} {} semilogy (@var{x}, @var{y}) +## @deftypefnx {Function File} {} semilogy (@var{x}, @var{y}, @var{property}, @var{value}, @dots{}) +## @deftypefnx {Function File} {} semilogy (@var{x}, @var{y}, @var{fmt}) +## @deftypefnx {Function File} {} semilogy (@var{h}, @dots{}) +## @deftypefnx {Function File} {@var{h} =} semilogy (@dots{}) ## Produce a two-dimensional plot using a logarithmic scale for the @var{y} -## axis. See the description of @code{plot} for a description of the +## axis. See the documentation of @code{plot} for a description of the ## arguments that @code{semilogy} will accept. ## @seealso{plot, semilogx, loglog} ## @end deftypefn @@ -29,7 +34,11 @@ function retval = semilogy (varargin) - [h, varargin] = __plt_get_axis_arg__ ("semilogy", varargin{:}); + [h, varargin, nargs] = __plt_get_axis_arg__ ("semilogy", varargin{:}); + + if (nargs < 1) + print_usage(); + endif oldh = gca (); unwind_protect