changeset 10730:390d93e20531

Plot commands now print usage information without errors when called with no arguments (bug #29986).
author Rik <octave@nomad.inbox5.com>
date Thu, 24 Jun 2010 12:22:27 -0700
parents 172253d75d94
children f5dbac015606
files scripts/ChangeLog scripts/plot/loglog.m scripts/plot/plot.m scripts/plot/polar.m scripts/plot/private/__plt__.m scripts/plot/semilogx.m scripts/plot/semilogy.m
diffstat 7 files changed, 57 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Thu Jun 24 14:39:32 2010 +0200
+++ b/scripts/ChangeLog	Thu Jun 24 12:22:27 2010 -0700
@@ -1,3 +1,10 @@
+2010-06-24  John W. Eaton  <jwe@octave.org>
+
+	* 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  <shaiay@users.sourceforge.net>
 
 	* plot/print.m: convert to wrapper for backend specific print functions
--- a/scripts/plot/loglog.m	Thu Jun 24 14:39:32 2010 +0200
+++ b/scripts/plot/loglog.m	Thu Jun 24 12:22:27 2010 -0700
@@ -18,9 +18,14 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- 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
--- a/scripts/plot/plot.m	Thu Jun 24 14:39:32 2010 +0200
+++ b/scripts/plot/plot.m	Thu Jun 24 12:22:27 2010 -0700
@@ -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
--- a/scripts/plot/polar.m	Thu Jun 24 14:39:32 2010 +0200
+++ b/scripts/plot/polar.m	Thu Jun 24 12:22:27 2010 -0700
@@ -18,7 +18,10 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- 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);
--- a/scripts/plot/private/__plt__.m	Thu Jun 24 14:39:32 2010 +0200
+++ b/scripts/plot/private/__plt__.m	Thu Jun 24 12:22:27 2010 -0700
@@ -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
--- a/scripts/plot/semilogx.m	Thu Jun 24 14:39:32 2010 +0200
+++ b/scripts/plot/semilogx.m	Thu Jun 24 12:22:27 2010 -0700
@@ -18,9 +18,14 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- 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
--- a/scripts/plot/semilogy.m	Thu Jun 24 14:39:32 2010 +0200
+++ b/scripts/plot/semilogy.m	Thu Jun 24 12:22:27 2010 -0700
@@ -18,9 +18,14 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- 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