Graphics    

The Current Figure, Axes, and Object

An important concept in Handle Graphics is that of being current. The current figure is the window designated to receive graphics output. Likewise, the current axes is the target for commands that create axes children. The current object is the last graphics object created or clicked on by the mouse.

MATLAB stores the three handles corresponding to these objects in the ancestor's property list.

These properties enable you to obtain the handles of these key objects.

The following commands are shorthand notation for the get statements.

You can use these commands as input arguments to functions that require object handles. For example, you can click on a line object and then use gco to specify the handle to the set command,

or list the values of all current axes properties with

You can get the handles of all the graphic objects in the current axes (except those with hidden handles),

and then determine the types of the objects.

While gcf and gca provide a simple means of obtaining the current figure and axes handles, they are less useful in M-files. This is particularly true if your M-file is part of an application layered on MATLAB where you do not necessarily have knowledge of user actions that can change these values.

See Controlling Graphics Output for information on how to prevent users from accessing the handles of graphics objects that you want to protect.


  Accessing Object Handles Searching for Objects by Property Values -- findobj