diff scripts/plot/hold.m @ 17129:b5d6314314fc

Change various plot functions to take advantage of new isaxes() function. * scripts/geometry/voronoi.m, scripts/image/imagesc.m, scripts/plot/__plt_get_axis_arg__.m, scripts/plot/axes.m, scripts/plot/cla.m, scripts/plot/colorbar.m, scripts/plot/hold.m, scripts/plot/legend.m, scripts/plot/plotmatrix.m, scripts/plot/plotyy.m, scripts/plot/private/__errplot__.m, scripts/plot/private/__plt__.m, scripts/plot/view.m: Use new isaxes function to simplify code. * scripts/plot/shading.m: Use Octave convention for spacing of parentheses. * scripts/plot/zlabel.m: Correct %!test incorrectly calling plot3 with figure handle.
author Rik <rik@octave.org>
date Wed, 31 Jul 2013 16:27:49 -0700
parents eaab03308c0b
children df4c4b7708a4
line wrap: on
line diff
--- a/scripts/plot/hold.m
+++ b/scripts/plot/hold.m
@@ -44,9 +44,6 @@
 ## Toggle the current hold state.
 ## @end table
 ##
-## If the first argument @var{hax} is an axes handle, 
-## rather than the current axes returned by @code{gca}.
-##
 ## When given the additional argument @var{hax}, the hold state is modified
 ## for this axis rather than the current axes returned by @code{gca}.
 ##
@@ -56,12 +53,10 @@
 
 function hold (varargin)
 
-  if (nargin > 0 && isscalar (varargin{1}) && ishandle (varargin{1})
-      && strcmp (get (varargin{1}, "type"), "axes"))
-    [hax, varargin, nargs] = __plt_get_axis_arg__ ("hold", varargin{:});
-    if (isempty (hax))
-      hax = gca ();
-    endif
+  if (nargin > 0 && isscalar (varargin{1}) && isaxes (varargin{1}))
+    hax = vargin{1};
+    varargin(1) = [];
+    nargs = numel (varargin);
     ## FIXME: Should this be ancestor (hax, "parent")?
     hfig = get (hax, "parent");
   elseif (nargin > 0 && numel (varargin{1}) > 1 && ishandle (varargin{1}))
@@ -76,19 +71,18 @@
   if (nargs == 0)
     turn_hold_off = ishold (hax);
   elseif (nargs == 1)
-    state = varargin{1};
-    if (ischar (state))
-      if (strcmpi (state, "off"))
+    state = tolower (varargin{1});
+    switch (state)
+      case "off"
         turn_hold_off = true;
-      elseif (strcmpi (state, "all"))
+      case "all"
         turn_hold_off = false;
         hold_all = true;
-      elseif (strcmpi (state, "on"))
+      case "on"
         turn_hold_off = false;
-      else
+      otherwise
         error ("hold: invalid hold STATE");
-      endif
-    endif
+    endswitch
   else
     print_usage ();
   endif