changeset 17069:1cbdd14711c5

scatter3.m, scatter.m: Update to use new __plt_get_axis_arg__. * scripts/plot/scatter3.m, scripts/plot/scatter.m: Update to use new __plt_get_axis_arg__.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 23 Jul 2013 18:31:22 +0200
parents 140d50ed8f22
children d465f9970c02
files scripts/plot/scatter.m scripts/plot/scatter3.m
diffstat 2 files changed, 19 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/scatter.m	Wed Jul 24 23:12:46 2013 -0700
+++ b/scripts/plot/scatter.m	Tue Jul 23 18:31:22 2013 +0200
@@ -61,23 +61,25 @@
 
 function retval = scatter (varargin)
 
-  [h, varargin, nargin] = __plt_get_axis_arg__ ("scatter", varargin{:});
+  [hax, varargin, nargin] = __plt_get_axis_arg__ ("scatter", varargin{:});
 
   if (nargin < 2)
     print_usage ();
   else
-    oldh = gca ();
+    oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
     unwind_protect
-      axes (h);
-      newplot ();
-      tmp = __scatter__ (h, 2, "scatter", varargin{:});
+      hax = newplot (hax);
+      
+      htmp = __scatter__ (hax, 2, "scatter", varargin{:});
     unwind_protect_cleanup
-      axes (oldh);
+    if (! isempty (oldfig))
+      set (0, "currentfigure", oldfig);
+    endif
     end_unwind_protect
   endif
 
   if (nargout > 0)
-    retval = tmp;
+    retval = htmp;
   endif
 
 endfunction
--- a/scripts/plot/scatter3.m	Wed Jul 24 23:12:46 2013 -0700
+++ b/scripts/plot/scatter3.m	Tue Jul 23 18:31:22 2013 +0200
@@ -56,23 +56,25 @@
 
 function retval = scatter3 (varargin)
 
-  [h, varargin, nargin] = __plt_get_axis_arg__ ("scatter3", varargin{:});
+  [hax, varargin, nargin] = __plt_get_axis_arg__ ("scatter3", varargin{:});
 
   if (nargin < 2)
     print_usage ();
   else
-    oldh = gca ();
+    oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
     unwind_protect
-      axes (h);
-      newplot ();
-      tmp = __scatter__ (h, 3, "scatter3", varargin{:});
+      hax = newplot (hax);
+      
+      tmp = __scatter__ (hax, 3, "scatter3", varargin{:});
     unwind_protect_cleanup
-      axes (oldh);
+      if (! isempty (oldfig))
+        set (0, "currentfigure", oldfig);
+      endif
     end_unwind_protect
   endif
 
-  if (! ishold ())
-    set (h, "view", [-37.5, 30],
+  if (! ishold (hax))
+    set (hax, "view", [-37.5, 30],
          "xgrid", "on", "ygrid", "on", "zgrid", "on");
   endif