# HG changeset patch # User Rik # Date 1382419515 25200 # Node ID 1ab8e21d9cfcdaf8454d5e02b5b27227f8c634f9 # Parent ed9a21a90221d5ddeabe215f32464fc111c91902 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. diff -r ed9a21a90221 -r 1ab8e21d9cfc scripts/plot/draw/surface.m --- a/scripts/plot/draw/surface.m Mon Sep 23 19:44:57 2013 +0200 +++ b/scripts/plot/draw/surface.m Mon Oct 21 22:25:15 2013 -0700 @@ -53,6 +53,8 @@ if (isempty (hax)) hax = gca (); + else + hax = hax(1); endif [htmp, bad_usage] = __surface__ (hax, varargin{:}); diff -r ed9a21a90221 -r 1ab8e21d9cfc scripts/plot/util/__plt_get_axis_arg__.m --- a/scripts/plot/util/__plt_get_axis_arg__.m Mon Sep 23 19:44:57 2013 +0200 +++ b/scripts/plot/util/__plt_get_axis_arg__.m Mon Oct 21 22:25:15 2013 -0700 @@ -28,7 +28,6 @@ h = []; parent = find (strcmpi (varargin, "parent"), 1); - ## Look for a scalar which is a graphics handle but not the ## Root Figure (0) or an ordinary figure (integer). if (numel (varargin) > 0 && numel (varargin{1}) == 1 @@ -50,7 +49,7 @@ varargin(parent:parent+1) = []; else ## 'parent' property for some other type like hggroup - h = htmp; + h = [ancestor(htmp, "axes"), htmp]; endif else error ("%s: expecting parent value to be axes handle", caller); diff -r ed9a21a90221 -r 1ab8e21d9cfc scripts/plot/util/newplot.m --- a/scripts/plot/util/newplot.m Mon Sep 23 19:44:57 2013 +0200 +++ b/scripts/plot/util/newplot.m Mon Oct 21 22:25:15 2013 -0700 @@ -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);