# HG changeset patch # User Pantxo Diribarne # Date 1374588367 -7200 # Node ID 3e1b24a2454a8745a51b44497774f511880e9d73 # Parent 9ff7d4849f0376928c694d3478150ea7085481d5 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. diff -r 9ff7d4849f03 -r 3e1b24a2454a scripts/plot/cylinder.m --- a/scripts/plot/cylinder.m Tue Jul 23 14:45:31 2013 +0200 +++ b/scripts/plot/cylinder.m Tue Jul 23 16:06:07 2013 +0200 @@ -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 diff -r 9ff7d4849f03 -r 3e1b24a2454a scripts/plot/ellipsoid.m --- a/scripts/plot/ellipsoid.m Tue Jul 23 14:45:31 2013 +0200 +++ b/scripts/plot/ellipsoid.m Tue Jul 23 16:06:07 2013 +0200 @@ -31,8 +31,7 @@ function [xx, yy, zz] = ellipsoid (varargin) - [h, varargin, nargin] = __plt_get_axis_arg__ ((nargout > 0), "ellipsoid", - varargin{:}); + [hax, varargin, nargin] = __plt_get_axis_arg__ ("ellipsoid", varargin{:}); if (nargin != 6 && nargin != 7) print_usage (); @@ -64,7 +63,17 @@ yy = y; zz = z; else - surf (h, 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 diff -r 9ff7d4849f03 -r 3e1b24a2454a scripts/plot/rectangle.m --- a/scripts/plot/rectangle.m Tue Jul 23 14:45:31 2013 +0200 +++ b/scripts/plot/rectangle.m Tue Jul 23 16:06:07 2013 +0200 @@ -55,10 +55,20 @@ [hax, varargin] = __plt_get_axis_arg__ ("rectangle", varargin{:}); - tmp = __rectangle__ (hax, varargin{:}); + oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + unwind_protect + hax = newplot (hax); + + htmp = __rectangle__ (hax, varargin{:}); + + unwind_protect_cleanup + if (! isempty (oldfig)) + set (0, "currentfigure", oldfig); + endif + end_unwind_protect if (nargout > 0) - h = tmp; + h = htmp; endif endfunction diff -r 9ff7d4849f03 -r 3e1b24a2454a scripts/plot/sphere.m --- a/scripts/plot/sphere.m Tue Jul 23 14:45:31 2013 +0200 +++ b/scripts/plot/sphere.m Tue Jul 23 16:06:07 2013 +0200 @@ -32,8 +32,8 @@ function [xx, yy, zz] = sphere (varargin) - [h, varargin, nargin] = __plt_get_axis_arg__ ((nargout > 0), "sphere", - varargin{:}); + [hax, varargin, nargin] = __plt_get_axis_arg__ ("sphere", varargin{:}); + if (nargin > 1) print_usage (); elseif (nargin == 1) @@ -55,7 +55,17 @@ yy = y; zz = z; else - surf (h, 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