Mercurial > hg > octave-terminal
changeset 7216:5389a52df87b
[project @ 2007-11-29 19:07:29 by jwe]
author | jwe |
---|---|
date | Thu, 29 Nov 2007 19:07:29 +0000 |
parents | dd88d61d443f |
children | c8abc18322b7 |
files | scripts/ChangeLog scripts/plot/__axes_limits__.m scripts/plot/__plt_get_axis_arg__.m scripts/plot/axis.m scripts/plot/caxis.m scripts/plot/contour.m scripts/plot/contour3.m scripts/plot/contourf.m scripts/plot/errorbar.m scripts/plot/fill.m scripts/plot/grid.m scripts/plot/loglog.m scripts/plot/loglogerr.m scripts/plot/meshz.m scripts/plot/patch.m scripts/plot/peaks.m scripts/plot/pie.m scripts/plot/plot.m scripts/plot/plotyy.m scripts/plot/polar.m scripts/plot/semilogx.m scripts/plot/semilogxerr.m scripts/plot/semilogy.m scripts/plot/semilogyerr.m scripts/plot/surf.m scripts/plot/surface.m scripts/plot/surfnorm.m |
diffstat | 27 files changed, 75 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,15 @@ +2007-11-29 John W. Eaton <jwe@octave.org> + + * plot/contour.m, plot/contour3.m, plot/fill.m, plot/patch.m, + plot/surf.m, plot/surface.m: Don't return handle value unless + requested. + + * plot/patch.m: Omit isnan check on handle returned from + __plt_get_axis_arg__. + + * plot/__plt_get_axis_arg__.m: Don't fail if current figure exists + but has no axes. + 2007-11-28 David Bateman <dbateman@free.fr> * __plt_get_axis_handle__.m: Also allow hggroup and return axes
--- a/scripts/plot/__axes_limits__.m +++ b/scripts/plot/__axes_limits__.m @@ -19,8 +19,10 @@ ## Undocumented internal function. function retval = __axes_limits__ (fcn, varargin) + retval = []; - fcnmode = sprintf("%smode", fcn); + + fcnmode = sprintf ("%smode", fcn); [h, varargin, nargin] = __plt_get_axis_arg__ (fcn, varargin{:}); @@ -45,4 +47,5 @@ endif endif endif + endfunction
--- a/scripts/plot/__plt_get_axis_arg__.m +++ b/scripts/plot/__plt_get_axis_arg__.m @@ -44,12 +44,17 @@ endif else f = get (0, "currentfigure"); - if (! isempty (f)) + if (isempty (f)) + h = []; + else h = get (f, 'currentaxes'); - elseif (nogca) - h = NaN; - else - h = gca (); + endif + if (isempty (h)) + if (nogca) + h = NaN; + else + h = gca (); + endif endif if (nargin < 2) varargin = {};
--- a/scripts/plot/axis.m +++ b/scripts/plot/axis.m @@ -119,6 +119,7 @@ function varargout = axis (varargin) [h, varargin, nargin] = __plt_get_axis_arg__ ("axis", varargin{:}); + oldh = gca (); unwind_protect axes (h);
--- a/scripts/plot/caxis.m +++ b/scripts/plot/caxis.m @@ -40,6 +40,7 @@ function varargout = caxis (varargin) [h, varargin, nargin] = __plt_get_axis_arg__ ("caxis", varargin{:}); + oldh = gca (); unwind_protect axes (h);
--- a/scripts/plot/contour.m +++ b/scripts/plot/contour.m @@ -49,12 +49,13 @@ function [c, h] = contour (varargin) - [h, varargin] = __plt_get_axis_arg__ ("contour", varargin{:}); + [xh, varargin] = __plt_get_axis_arg__ ("contour", varargin{:}); + oldh = gca (); unwind_protect - axes (h); + axes (xh); newplot (); - [ctmp, htmp] = __contour__ (h, NaN, varargin{:}); + [ctmp, htmp] = __contour__ (xh, NaN, varargin{:}); unwind_protect_cleanup axes (oldh); end_unwind_protect
--- a/scripts/plot/contour3.m +++ b/scripts/plot/contour3.m @@ -46,18 +46,19 @@ function [c, h] = contour3 (varargin) - [h, varargin, nargin] = __plt_get_axis_arg__ ("contour3", varargin{:}); + [xh, varargin, nargin] = __plt_get_axis_arg__ ("contour3", varargin{:}); + oldh = gca (); unwind_protect - axes (h); + axes (xh); newplot (); - [ctmp, htmp] = __contour__ (h, "level", varargin{:}); + [ctmp, htmp] = __contour__ (xh, "level", varargin{:}); unwind_protect_cleanup axes (oldh); end_unwind_protect if (! ishold ()) - set (h, "view", [-37.5, 30]); + set (xh, "view", [-37.5, 30]); endif if (nargout > 0)
--- a/scripts/plot/contourf.m +++ b/scripts/plot/contourf.m @@ -60,8 +60,11 @@ function varargout = contourf (varargin) [ax, varargin] = __plt_get_axis_arg__ ("contourf", varargin{:}); + [X, Y, Z, lvl, patch_props] = parse_args (varargin); + [nr, nc] = size (Z); + [minx, maxx] = deal (min (X(:)), max (X(:))); [miny, maxy] = deal (min (Y(:)), max (Y(:)));
--- a/scripts/plot/errorbar.m +++ b/scripts/plot/errorbar.m @@ -111,6 +111,7 @@ function errorbar (varargin) [h, varargin] = __plt_get_axis_arg__ ("errorbar", varargin{:}); + oldh = gca (); unwind_protect axes (h);
--- a/scripts/plot/fill.m +++ b/scripts/plot/fill.m @@ -25,11 +25,13 @@ ## Create one or more filled patch objects, returning a patch object for each. ## @end deftypefn -function h = fill (varargin) +function retval = fill (varargin) [h, varargin] = __plt_get_axis_arg__ ("fill", varargin{:}); + htmp = []; iargs = __find_patches__ (varargin{:}); + oldh = gca (); unwind_protect axes (h); @@ -52,7 +54,7 @@ end_unwind_protect if (nargout > 0) - h = htmp; + retval = htmp; endif endfunction
--- a/scripts/plot/grid.m +++ b/scripts/plot/grid.m @@ -41,6 +41,7 @@ persistent minor_on = false; [ax, varargin, nargs] = __plt_get_axis_arg__ ("grid", varargin{:}); + if (nargs > 1) print_usage (); elseif (nargs == 0)
--- a/scripts/plot/loglog.m +++ b/scripts/plot/loglog.m @@ -30,6 +30,7 @@ function retval = loglog (varargin) [h, varargin] = __plt_get_axis_arg__ ("loglog", varargin{:}); + oldh = gca (); unwind_protect axes (h); @@ -42,7 +43,6 @@ if (nargout > 0) retval = tmp; endif - unwind_protect_cleanup axes (oldh); end_unwind_protect
--- a/scripts/plot/loglogerr.m +++ b/scripts/plot/loglogerr.m @@ -41,6 +41,7 @@ function retval = loglogerr (varargin) [h, varargin] = __plt_get_axis_arg__ ("loglogerr", varargin{:}); + oldh = gca (); unwind_protect axes (h); @@ -53,7 +54,6 @@ if (nargout > 0) retval = tmp; endif - unwind_protect_cleanup axes (oldh); end_unwind_protect
--- a/scripts/plot/meshz.m +++ b/scripts/plot/meshz.m @@ -32,7 +32,7 @@ [h, varargin, nargin] = __plt_get_axis_arg__ ("meshz", varargin{:}); ioff = nargin + 1; - for i = 1 : nargin + for i = 1:nargin if (ischar (varargin{i})) ioff = i; break; @@ -47,8 +47,8 @@ if (ioff == 2) z = varargin{1}; [m, n] = size (z); - x = 1 : n; - y = (1 : m).'; + x = 1:n; + y = (1:m).'; else x = varargin{1}; y = varargin{2};
--- a/scripts/plot/patch.m +++ b/scripts/plot/patch.m @@ -34,13 +34,12 @@ ## Author: jwe -function h = patch (varargin) +function retval = patch (varargin) [h, varargin] = __plt_get_axis_arg__ ("patch", varargin{:}); + oldh = gca (); - if (isnan(h)) - h = oldh; - endif + unwind_protect axes (h); [tmp, fail] = __patch__ (h, varargin{:}); @@ -53,7 +52,7 @@ endif if (nargout > 0) - h = tmp; + retval = tmp; endif endfunction
--- a/scripts/plot/peaks.m +++ b/scripts/plot/peaks.m @@ -54,17 +54,17 @@ function [X_out, Y_out, Z_out] = peaks (x, y) - if nargin == 0 - x = y = linspace(-3,3,49); - elseif nargin == 1 + if (nargin == 0) + x = y = linspace (-3, 3, 49); + elseif (nargin == 1) if length(x) > 1 y = x; else - x = y = linspace(-3,3,x); + x = y = linspace (-3, 3, x); endif endif - if (isvector(x) && isvector(y)) + if (isvector (x) && isvector (y)) [X, Y] = meshgrid (x, y); else X = x; @@ -75,9 +75,9 @@ - 10 * (X / 5 - X .^ 3 - Y .^ 5) .* exp(- X .^ 2 - Y .^ 2) \ - 1 / 3 * exp(- (X + 1) .^ 2 - Y .^ 2); - if nargout == 0 + if (nargout == 0) mesh (x, y, Z); - elseif nargout == 1 + elseif (nargout == 1) X_out = Z; else X_out = X;
--- a/scripts/plot/pie.m +++ b/scripts/plot/pie.m @@ -59,7 +59,6 @@ end_unwind_protect endif - if (nargout > 0) retval = tmp; endif
--- a/scripts/plot/plot.m +++ b/scripts/plot/plot.m @@ -179,6 +179,7 @@ function retval = plot (varargin) [h, varargin] = __plt_get_axis_arg__ ("plot", varargin{:}); + oldh = gca (); unwind_protect axes (h);
--- a/scripts/plot/plotyy.m +++ b/scripts/plot/plotyy.m @@ -60,6 +60,7 @@ if (nargin < 4) print_usage (); endif + oldh = gca (); unwind_protect axes (ax);
--- a/scripts/plot/polar.m +++ b/scripts/plot/polar.m @@ -31,6 +31,7 @@ function retval = polar (varargin) [h, varargin] = __plt_get_axis_arg__ ("polar", varargin{:}); + oldh = gca (); unwind_protect axes (h); @@ -60,7 +61,6 @@ if (nargout > 0) retval = tmp; endif - unwind_protect_cleanup axes (oldh); end_unwind_protect
--- a/scripts/plot/semilogx.m +++ b/scripts/plot/semilogx.m @@ -30,6 +30,7 @@ function retval = semilogx (varargin) [h, varargin] = __plt_get_axis_arg__ ("semilogx", varargin{:}); + oldh = gca (); unwind_protect axes (h); @@ -42,7 +43,6 @@ if (nargout > 0) retval = tmp; endif - unwind_protect_cleanup axes (oldh); end_unwind_protect
--- a/scripts/plot/semilogxerr.m +++ b/scripts/plot/semilogxerr.m @@ -41,6 +41,7 @@ function retval = semilogxerr (varargin) [h, varargin] = __plt_get_axis_arg__ ("semilogxerr", varargin{:}); + oldh = gca (); unwind_protect axes (h); @@ -53,7 +54,6 @@ if (nargout > 0) retval = tmp; endif - unwind_protect_cleanup axes (oldh); end_unwind_protect
--- a/scripts/plot/semilogy.m +++ b/scripts/plot/semilogy.m @@ -30,6 +30,7 @@ function retval = semilogy (varargin) [h, varargin] = __plt_get_axis_arg__ ("semilogy", varargin{:}); + oldh = gca (); unwind_protect axes (h);
--- a/scripts/plot/semilogyerr.m +++ b/scripts/plot/semilogyerr.m @@ -41,6 +41,7 @@ function retval = semilogyerr (varargin) [h, varargin] = __plt_get_axis_arg__ ("semilogyerr", varargin{:}); + oldh = gca (); unwind_protect axes (h); @@ -53,7 +54,6 @@ if (nargout > 0) retval = tmp; endif - unwind_protect_cleanup axes (oldh); end_unwind_protect
--- a/scripts/plot/surf.m +++ b/scripts/plot/surf.m @@ -29,7 +29,7 @@ ## Author: Kai Habel <kai.habel@gmx.de> -function h = surf (varargin) +function retval = surf (varargin) [h, varargin] = __plt_get_axis_arg__ ("surf", varargin{:}); @@ -48,7 +48,7 @@ end_unwind_protect if (nargout > 0) - h = tmp; + retval = tmp; endif endfunction
--- a/scripts/plot/surface.m +++ b/scripts/plot/surface.m @@ -39,7 +39,7 @@ ## Author: jwe -function h = surface (varargin) +function retval = surface (varargin) [h, varargin] = __plt_get_axis_arg__ ("surface", varargin{:}); @@ -56,8 +56,9 @@ endif if (nargout > 0) - h = tmp; + retval = tmp; endif + endfunction function [h, bad_usage] = __surface__ (ax, varargin)