changeset 17050:9ff7d4849f03

contour[3f].m: Update to use new __plt_get_axis_arg__. * scripts/plot/contourf.m, scripts/plot/contour3.m, scripts/plot/contour.m: Update to use new __plt_get_axis_arg__. Rename xh to hax.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 23 Jul 2013 14:45:31 +0200
parents 0322e057697f
children 3e1b24a2454a
files scripts/plot/contour.m scripts/plot/contour3.m scripts/plot/contourf.m
diffstat 3 files changed, 27 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/contour.m	Tue Jul 23 15:10:57 2013 +0200
+++ b/scripts/plot/contour.m	Tue Jul 23 14:45:31 2013 +0200
@@ -52,15 +52,18 @@
 
 function [c, h] = contour (varargin)
 
-  [xh, varargin] = __plt_get_axis_arg__ ("contour", varargin{:});
+  [hax, varargin] = __plt_get_axis_arg__ ("contour", varargin{:});
 
-  oldh = gca ();
+  oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
   unwind_protect
-    axes (xh);
-    newplot ();
-    [ctmp, htmp] = __contour__ (xh, "none", varargin{:});
+    hax = newplot (hax);
+    
+    [ctmp, htmp] = __contour__ (hax, "none", varargin{:});
+    
   unwind_protect_cleanup
-    axes (oldh);
+    if (! isempty (oldfig))
+      set (0, "currentfigure", oldfig);
+    endif
   end_unwind_protect
 
   if (nargout > 0)
--- a/scripts/plot/contour3.m	Tue Jul 23 15:10:57 2013 +0200
+++ b/scripts/plot/contour3.m	Tue Jul 23 14:45:31 2013 +0200
@@ -51,19 +51,21 @@
 
 function [c, h] = contour3 (varargin)
 
-  [xh, varargin, nargin] = __plt_get_axis_arg__ ("contour3", varargin{:});
+  [hax, varargin, nargin] = __plt_get_axis_arg__ ("contour3", varargin{:});
 
-  oldh = gca ();
+  oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
   unwind_protect
-    axes (xh);
-    newplot ();
-    [ctmp, htmp] = __contour__ (xh, "auto", varargin{:});
+    hax = newplot (hax);
+    
+    [ctmp, htmp] = __contour__ (hax, "auto", varargin{:});
   unwind_protect_cleanup
-    axes (oldh);
+    if (! isempty (oldfig))
+      set (0, "currentfigure", oldfig);
+    endif
   end_unwind_protect
 
   if (! ishold ())
-    set (xh, "view", [-37.5, 30],
+    set (hax, "view", [-37.5, 30],
          "xgrid", "on", "ygrid", "on", "zgrid", "on");
   endif
 
--- a/scripts/plot/contourf.m	Tue Jul 23 15:10:57 2013 +0200
+++ b/scripts/plot/contourf.m	Tue Jul 23 14:45:31 2013 +0200
@@ -66,16 +66,19 @@
 
 function [c, h] = contourf (varargin)
 
-  [xh, varargin] = __plt_get_axis_arg__ ("contour", varargin{:});
+  [hax, varargin] = __plt_get_axis_arg__ ("contour", varargin{:});
 
-  oldh = gca ();
+  oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
   unwind_protect
-    axes (xh);
-    newplot ();
-    [ctmp, htmp] = __contour__ (xh, "none", "fill", "on",
+    hax = newplot (hax);
+    
+    [ctmp, htmp] = __contour__ (hax, "none", "fill", "on",
                                 "linecolor", "black", varargin{:});
+    
   unwind_protect_cleanup
-    axes (oldh);
+    if (! isempty (oldfig))
+      set (0, "currentfigure", oldfig);
+    endif
   end_unwind_protect
 
   if (nargout > 0)