diff scripts/plot/sphere.m @ 17051:3e1b24a2454a

cylinder.m, ellipsoid.m, rectangle.m, sphere.m: Update to use new __plt_get_axis_arg__. * scripts/plot/cylinder.m, scripts/plot/ellipsoid.m, scripts/plot/rectangle.m, scripts/plot/sphere.m: Update to use new __plt_get_axis_arg__. Rename ax to hax.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 23 Jul 2013 16:06:07 +0200
parents 72c96de7a403
children eaab03308c0b
line wrap: on
line diff
--- a/scripts/plot/sphere.m
+++ b/scripts/plot/sphere.m
@@ -32,8 +32,8 @@
 
 function [xx, yy, zz] = sphere (varargin)
 
-  [h, varargin, nargin] = __plt_get_axis_arg__ ((nargout > 0), "sphere",
-                                                varargin{:});
+  [hax, varargin, nargin] = __plt_get_axis_arg__ ("sphere", varargin{:});
+
   if (nargin > 1)
     print_usage ();
   elseif (nargin == 1)
@@ -55,7 +55,17 @@
     yy = y;
     zz = z;
   else
-    surf (h, x, y, z);
+    oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
+    unwind_protect
+      hax = newplot (hax);
+    
+      surf (hax, x, y, z);
+      
+    unwind_protect_cleanup
+      if (! isempty (oldfig))
+        set (0, "currentfigure", oldfig);
+      endif
+    end_unwind_protect
   endif
 
 endfunction