# HG changeset patch # User Rik # Date 1374732766 25200 # Node ID 6dec8dbf8a970f96aa0e46c049062301bd7dcbe8 # Parent cec8c423b3e8f3c533a0450b57fe347b60a37494 axis.m: Overhaul to use new __plt_get_axis_arg__. * scripts/plot/axis.m: Use hax instead of h. Use gca if hax not set. Rename output of function to match documentation. diff -r cec8c423b3e8 -r 6dec8dbf8a97 scripts/plot/axis.m --- a/scripts/plot/axis.m Wed Jul 24 23:12:46 2013 -0700 +++ b/scripts/plot/axis.m Wed Jul 24 23:12:46 2013 -0700 @@ -130,26 +130,29 @@ ## Author: jwe -function varargout = axis (varargin) +function limits = axis (varargin) - [h, varargin, nargin] = __plt_get_axis_arg__ ("axis", varargin{:}); + [hax, varargin, nargin] = __plt_get_axis_arg__ ("axis", varargin{:}); - oldh = gca (); + oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); unwind_protect - axes (h); - varargout = cell (max (nargin == 0, nargout), 1); - if (isempty (varargout)) - __axis__ (h, varargin{:}); + if (isempty (hax)) + hax = gca (); + endif + if (nargin == 0) + limits = __axis__ (hax, varargin{:}); else - [varargout{:}] = __axis__ (h, varargin{:}); + __axis__ (hax, varargin{:}); endif unwind_protect_cleanup - axes (oldh); + if (! isempty (oldfig)) + set (0, "currentfigure", oldfig); + endif end_unwind_protect endfunction -function curr_axis = __axis__ (ca, ax, varargin) +function limits = __axis__ (ca, ax, varargin) if (nargin == 1) if (nargout == 0) @@ -159,10 +162,10 @@ ylim = get (ca, "ylim"); view = get (ca, "view"); if (view(2) == 90) - curr_axis = [xlim, ylim]; + limits = [xlim, ylim]; else zlim = get (ca, "zlim"); - curr_axis = [xlim, ylim, zlim]; + limits = [xlim, ylim, zlim]; endif endif @@ -369,6 +372,7 @@ endfunction + %!demo %! clf; %! t = 0:0.01:2*pi;