next up previous contents
Next: Graphics Hardcopy Up: Graphics Previous: 2-D Graphics

Handles

 

A handle is a special MATLAB object attached to part of a plot that lets you find and change the properties of that part. The boolean ishandle tests whether something is a handle.

A plot always has at least two parts with handles, the figure and the axis. The former has general characteristics of the entire window; the latter has characteristics of the axes. The special constant gcf (for get current figure) is a handle to the current plot's figure; gca (get current axis) is a handle to the current plot's axis; and gco (object) is a handle to the last piece of the plot you clicked on with the mouse. Various graphics commands return handles; generally a handle is returned by any function that creates or adds something to a plot. figure, axes, and text all do this. See the help entries for specific other functions for their return values.

Objects with handles have properties. Each property has a name, which is a text string. The value of a property of an object is given by get(handle, propertyname); if the property name is omitted, all properties are listed (with their names). You change these values with set, whose most general format is set(vector of handles, property name, property value, another property name, value for that property, a third property name, value for third property, ...). For each handle in the vector (a single handle is fine), each given property is set to the specified value. Omitting the property values will display the possible values for the specified property, with curly braces {} around the current value. Also omitting the property names gives such a list for all the object's properties.

Some objects have children, which are objects under them; you can get handles to these objects from their parent by getting the 'Children' property. You can tell a parent that you want its children to have certain defaults unless they override; set on the parent the property of 'Default' followed by the name fo the object type (given by the 'Type' property) followed by the defaulting property name (e.g. 'DefaultTextColor').

Three special property values can be given for any property. Giving 'default' resets the property to its default value as affected by any parental defaults; giving 'factory' sets to the default value ignoring any parental defaults. The 'remove' value removes the default value.

To return all properties (except position) to the factory defaults use reset. An object can be destroyed with delete(handle). The findobj function can be used to seek for objects with given property values.

A typical strategy is to get handles to the top objects, look through their children for the object you want, look through its properties for the one you want, see what possible values it has, and set the one you want.


next up previous contents
Next: Graphics Hardcopy Up: Graphics Previous: 2-D Graphics

sepherke
Sat Mar 21 21:42:28 EST 1998