Mercurial > hg > octave-lyh
diff scripts/plot/ishold.m @ 13319:eb0ce6ffefb0
ishold: don't create axes if none exists
* ishold.m: Don't create axes object if none exists.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 11 Oct 2011 16:15:35 -0400 |
parents | be7bfd59300a |
children | 72c96de7a403 |
line wrap: on
line diff
--- a/scripts/plot/ishold.m +++ b/scripts/plot/ishold.m @@ -30,16 +30,12 @@ function retval = ishold (h) if (nargin == 0) - ax = gca (); fig = gcf (); + ax = get (fig, "currentaxes"); elseif (nargin == 1) if (ishandle (h)) if (isfigure (h)) ax = get (h, "currentaxes"); - if (isempty (ax)) - ax = __go_axes__ (h); - set (h, "currentaxes", ax); - endif fig = h; elseif (strcmpi (get (h, "type"), "axes")) ax = h; @@ -55,13 +51,16 @@ endif retval = (strcmpi (get (fig, "nextplot"), "add") - && strcmpi (get (ax, "nextplot"), "add")); + && ! isempty (ax) && strcmpi (get (ax, "nextplot"), "add")); endfunction %!test %! hf = figure ("visible", "off"); %! unwind_protect +%! assert (!ishold); +%! assert (isempty (get (hf, "currentaxes"))); +%! assert (get (hf, "NextPlot"), "add"); %! l = plot ([0 1]); %! assert (!ishold); %! assert (!ishold (gca));