Skip to Main Content Skip to Search
Product Documentation

hggroup - Create hggroup object

Syntax

h = hggroup
h = hggroup(...,'PropertyName',propertyvalue,...)

Properties

For a list of properties, see Hggroup Properties.

Description

h = hggroup creates an hggroup object as a child of the current axes and returns its handle, h.

h = hggroup(...,'PropertyName',propertyvalue,...) creates an hggroup object with the property values specified in the argument list. For a description of the properties, see Hggroup Properties.

An hggroup object can be the parent of any axes children except light objects, as well as other hggroup objects. You can use hggroup objects to form a group of objects that can be treated as a single object with respect to the following cases:

Examples

This example defines a callback for the ButtonDownFcn property of an hggroup object. In order for the hggroup to receive the mouse button down event that executes the ButtonDownFcn callback, the HitTest properties of all the line objects must be set to off. The event is then passed up the hierarchy to the hggroup.

The following function creates a random set of lines that are parented to an hggroup object. The subfunction set_lines defines a callback that executes when the mouse button is pressed over any of the lines. The callback simply increases the widths of all the lines by 1 with each button press.

function doc_hggroup
hg = hggroup('ButtonDownFcn',@set_lines);
hl  = line(randn(5),randn(5),'HitTest','off','Parent',hg);

function set_lines(cb,eventdata)
hl = get(cb,'Children');% cb is handle of hggroup object
lw = get(hl,'LineWidth');% get current line widths
set(hl,{'LineWidth'},num2cell([lw{:}]+1,[5,1])')

Note that selecting any one of the lines selects all the lines. (To select an object, enable plot edit mode by selecting Plot Edit from the Tools menu.)

Instance Diagram for This Example

The following diagram shows the object hierarchy created by this example.

Setting Default Properties

You can set default hggroup properties on the axes, figure, and root object levels:

set(0,'DefaultHggroupProperty',PropertyValue...)
set(gcf,'DefaultHggroupProperty',PropertyValue...)
set(gca,'DefaultHggroupProperty',PropertyValue...)

where Property is the name of the hggroup property whose default value you want to set and PropertyValue is the value you are specifying. Use set and get to access the hggroup properties.

See Also

Hggroup Properties | hgtransform

How To

  


» Learn more
» Download free kit
» Get trial software

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