changeset 17070:d465f9970c02

quiver.m, quiver3.m: Upgrade to use new __plt_get_axis_arg__. * scripts/plot/quiver.m, scripts/plot/quiver3.m: Upgrade to use new __plt_get_axis_arg__.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 23 Jul 2013 18:44:37 +0200
parents 1cbdd14711c5
children e89fd58a6e84
files scripts/plot/private/__quiver__.m scripts/plot/quiver.m scripts/plot/quiver3.m
diffstat 3 files changed, 23 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/private/__quiver__.m	Tue Jul 23 18:31:22 2013 +0200
+++ b/scripts/plot/private/__quiver__.m	Tue Jul 23 18:44:37 2013 +0200
@@ -284,7 +284,7 @@
       endif
     endif
     if (have_filled)
-      ## FIXME gnuplot doesn't respect the markerfacecolor field
+      ## FIXME: gnuplot doesn't respect the markerfacecolor field
       set (h3, "markerfacecolor", get (h1, "color"));
     endif
 
--- a/scripts/plot/quiver.m	Tue Jul 23 18:31:22 2013 +0200
+++ b/scripts/plot/quiver.m	Tue Jul 23 18:44:37 2013 +0200
@@ -60,23 +60,24 @@
 
 function retval = quiver (varargin)
 
-  [h, varargin, nargin] = __plt_get_axis_arg__ ("quiver", varargin{:});
+  [hax, varargin, nargin] = __plt_get_axis_arg__ ("quiver", varargin{:});
 
   if (nargin < 2)
     print_usage ();
   else
-    oldh = gca ();
+    oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
     unwind_protect
-      axes (h);
-      newplot ();
-      tmp = __quiver__ (h, 0, varargin{:});
+      hax = newplot (hax);
+      htmp = __quiver__ (hax, false, 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/quiver3.m	Tue Jul 23 18:31:22 2013 +0200
+++ b/scripts/plot/quiver3.m	Tue Jul 23 18:44:37 2013 +0200
@@ -63,23 +63,28 @@
 
 function retval = quiver3 (varargin)
 
-  [h, varargin, nargin] = __plt_get_axis_arg__ ("quiver3", varargin{:});
+  [hax, varargin, nargin] = __plt_get_axis_arg__ ("quiver3", varargin{:});
 
   if (nargin < 2)
     print_usage ();
   else
-    oldh = gca ();
+    oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
     unwind_protect
-      axes (h);
-      newplot ();
-      tmp = __quiver__ (h, 1, varargin{:});
+      hax = newplot (hax);
+      htmp = __quiver__ (hax, true, varargin{:});
+
+      if (! ishold (hax))
+        set (hax, "view", [-37.5, 30]);  # 3D view
+      endif
     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
@@ -91,9 +96,9 @@
 %! [x,y] = meshgrid (-1:0.1:1);
 %! z = sin (2*pi * sqrt (x.^2 + y.^2));
 %! theta = 2*pi * sqrt (x.^2 + y.^2) + pi/2;
-%! quiver3 (x, y, z, sin (theta), cos (theta), ones (size (z)));
+%! mesh (x, y, z);
 %! hold on;
-%! mesh (x, y, z);
+%! quiver3 (x, y, z, sin (theta), cos (theta), ones (size (z)));
 %! hold off;
 
 %!demo