Mercurial > hg > octave-lyh
changeset 17051:3e1b24a2454a
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.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Tue, 23 Jul 2013 16:06:07 +0200 |
parents | 9ff7d4849f03 |
children | 1118d566bcd4 |
files | scripts/plot/cylinder.m scripts/plot/ellipsoid.m scripts/plot/rectangle.m scripts/plot/sphere.m |
diffstat | 4 files changed, 49 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/cylinder.m +++ b/scripts/plot/cylinder.m @@ -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
--- a/scripts/plot/ellipsoid.m +++ b/scripts/plot/ellipsoid.m @@ -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
--- a/scripts/plot/rectangle.m +++ b/scripts/plot/rectangle.m @@ -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
--- a/scripts/plot/sphere.m +++ b/scripts/plot/sphere.m @@ -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