Mercurial > hg > octave-nkf
diff scripts/plot/util/newplot.m @ 17720:1ab8e21d9cfc
Further corrections to parenting of axes (bug #39813)
* scripts/plot/util/newplot.m: Accept multiple graphic handles to save.
Also save handles when axis nextplot property is "replacechildren".
Correct failing %!test.
* scripts/plot/util/__plt_get_axis_arg__.m: Return axis as first value,
"parent" handle as second value.
* scripts/plot/draw/surface.m: Get axis from __plt_get_axis_arg__ and ignore
any other returned handles.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 21 Oct 2013 22:25:15 -0700 |
parents | ed9a21a90221 |
children | d63878346099 |
line wrap: on
line diff
--- a/scripts/plot/util/newplot.m +++ b/scripts/plot/util/newplot.m @@ -91,12 +91,19 @@ if (! isempty (hsave)) ## Find the first valid axes ca = ancestor (hsave, "axes", "toplevel"); + if (iscell (ca)) + ca = [ca{:}]; + endif ca = ca(find (ca, 1)); + hsave(hsave == ca) = []; ## Next, find the figure associated with any axis found if (! isempty (ca)) cf = ancestor (ca, "figure", "toplevel"); else cf = ancestor (hsave, "figure", "toplevel"); + if (iscell (cf)) + cf = [cf{:}]; + endif cf = cf(find (cf, 1)); endif endif @@ -159,7 +166,18 @@ case "add" ## Default case. Doesn't require action. case "replacechildren" - delete (get (ca, "children")); + if (! deleteall && ca != hsave) + ## preserve hsave and its parents, uncles, ... + kids = allchild (ca); + hkid = hsave; + while (! any (hkid == kids)) + hkid = get (hkid, "parent"); + endwhile + kids(kids == hkid) = []; + delete (kids); + else + delete (get (ca, "children")); + endif case "replace" if (! deleteall && ca != hsave) ## preserve hsave and its parents, uncles, ... @@ -223,7 +241,7 @@ %! ## kids are preserved for hggroups %! kids = get (hg1, "children"); %! newplot (hg1); -%! assert (get (hg1, "children"), kids)); +%! assert (get (hg1, "children"), kids); %! %! ## preserve objects %! newplot (li1);