ancestor - Ancestor of graphics object

Syntax

p = ancestor(h,type)
p = ancestor(h,type,'toplevel')

Description

p = ancestor(h,type) returns the handle of the closest ancestor of h, if the ancestor is one of the types of graphics objects specified by type. type can be:

If MATLAB cannot find an ancestor of h that is one of the specified types, then ancestor returns p as empty.

Note that ancestor returns p as empty but does not issue an error if h is not the handle of a Handle Graphics object.

p = ancestor(h,type,'toplevel') returns the highest-level ancestor of h, if this type appears in the type argument.

Examples

Create some line objects and parent them to an hggroup object.

hgg = hggroup;
hgl = line(randn(5),randn(5),'Parent',hgg);

Now get the ancestor of the lines.

p = ancestor(hgg,{'figure','axes','hggroup'});
get(p,'Type')
ans =

hggroup

Now get the top-level ancestor

p=ancestor(hgg,{'figure','axes','hggroup'},'toplevel');
get(p,'type')
ans =

figure

See Also

findobj

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS