changeset 17062:2d17dbdf6b7d

comet.m, comet3.m: Update to use new __plt_get_axis_arg__. * scripts/plot/comet.m, scripts/plot/comet3.m: Update to use new __plt_get_axis_arg__.
author Rik <rik@octave.org>
date Wed, 24 Jul 2013 23:12:46 -0700
parents c935a0db31c6
children cae21eadc27b
files scripts/plot/comet.m scripts/plot/comet3.m
diffstat 2 files changed, 20 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/comet.m
+++ b/scripts/plot/comet.m
@@ -39,7 +39,7 @@
 
 function comet (varargin)
 
-  [h, varargin, nargin] = __plt_get_axis_arg__ ("comet", varargin{:});
+  [hax, varargin, nargin] = __plt_get_axis_arg__ ("comet", varargin{:});
 
   if (nargin == 0)
     print_usage ();
@@ -57,24 +57,25 @@
     p = varargin{3};
   endif
 
-  oldh = gca ();
+  oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
   unwind_protect
-    axes (h);
-    newplot ();
-    theaxis = [min(x), max(x), min(y), max(y)];
+    hax = newplot (hax);
+    limits = [min(x), max(x), min(y), max(y)];
     num = numel (y);
     dn = round (num/10);
     for n = 1:(num+dn);
       m = n - dn;
       m = max ([m, 1]);
       k = min ([n, num]);
-      h = plot (x(1:m), y(1:m), "r", x(m:k), y(m:k), "g", x(k), y(k), "ob");
-      axis (theaxis);
+      plot (hax, x(1:m), y(1:m), "r", x(m:k), y(m:k), "g", x(k), y(k), "ob");
+      axis (hax, limits);
       drawnow ();
       pause (p);
     endfor
   unwind_protect_cleanup
-    axes (oldh);
+    if (! isempty (oldfig))
+      set (0, "currentfigure", oldfig);
+    endif
   end_unwind_protect
 
 endfunction
--- a/scripts/plot/comet3.m
+++ b/scripts/plot/comet3.m
@@ -39,7 +39,7 @@
 
 function comet3 (varargin)
 
-  [h, varargin, nargin] = __plt_get_axis_arg__ ("comet3", varargin{:});
+  [hax, varargin, nargin] = __plt_get_axis_arg__ ("comet3", varargin{:});
 
   if (nargin == 0 || nargin == 2 || nargin > 4)
     print_usage ();
@@ -59,25 +59,27 @@
     p = varargin{4};
   endif
 
-  oldh = gca ();
+  oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
   unwind_protect
-    axes (h);
-    newplot ();
-    theaxis = [min(x), max(x), min(y), max(y), min(z), max(z)];
+    hax = newplot (hax);
+    limits = [min(x), max(x), min(y), max(y), min(z), max(z)];
     num = numel (y);
     dn = round (num/10);
     for n = 1:(num+dn);
       m = n - dn;
       m = max ([m, 1]);
       k = min ([n, num]);
-      h = plot3 (x(1:m), y(1:m), z(1:m), "r", x(m:k), y(m:k), z(m:k), "g",
-                 x(k), y(k), z(k), "ob");
-      axis (theaxis);
+      htmp = plot3 (hax, x(1:m), y(1:m), z(1:m), "r",
+                         x(m:k), y(m:k), z(m:k), "g",
+                         x(k), y(k), z(k), "ob");
+      axis (limits);
       drawnow ();
       pause (p);
     endfor
   unwind_protect_cleanup
-    axes (oldh);
+    if (! isempty (oldfig))
+      set (0, "currentfigure", oldfig);
+    endif
   end_unwind_protect
 
 endfunction