diff scripts/plot/cylinder.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 5d3a684236b0
children eaab03308c0b
line wrap: on
line diff
--- a/scripts/plot/cylinder.m
+++ b/scripts/plot/cylinder.m
@@ -48,8 +48,7 @@
 
 function [xx, yy, zz] = cylinder (varargin)
 
-  [ax, args, nargs] = __plt_get_axis_arg__ ((nargout > 0), "cylinder",
-                                            varargin{:});
+  [hax, args, nargs] = __plt_get_axis_arg__ ("cylinder", varargin{:});
 
   if (nargs == 0)
     n = 20;
@@ -80,7 +79,17 @@
     yy = y;
     zz = z;
   else
-    surf (ax, 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