In some situations it is important to prevent particular figures
or axes from becoming the target for graphics output. That is, prevent
them from becoming the current figure, as returned by
gcf, or the current axes, as returned
You might want to prevent access to a figure containing the controls that implement a user interface. Or, you might want to prevent access to an axes that is part of an application program accessed only by the application.
Prevent MATLAB® functions from targeting a particular figure or axes by removing their handles from the list of visible handles.
Two properties control handle visibility:
HandleVisibility is a property of all graphics
objects. It controls the visibility of the object’s handle
to three possible values:
callback — The object's
handle is visible only within the workspace of a callback function.
off — The handle is hidden
from all functions executing in the command window and in callback
When an object’s
When a handle is not visible in its parent's list of children,
functions that obtain handles by searching the object hierarchy cannot
return the handle. These functions include
When a hidden-handle figure is topmost on the screen, but has
visible-handle figures stacked behind it,
the topmost visible-handle figure in the stack. The same behavior
is true for
gca. If no visible-handle
figures or axes exist, calling
ShowHiddenHandles property enables and
disables handle visibility control. By default,
which means MATLAB follows the setting of every object’s
equivalent to setting the
of all objects in the graphics hierarchy to
close function also
allows access to hidden-handle figures using the
closes the topmost figure on the screen, even if its handle is hidden.
closes all figures.
All handles remain valid regardless of the state of their
If you have assigned an object handle to a variable, you can always
set and get its properties using that handle variable.