Graphics Previous page   Next Page

Graphics Windows -- the Figure

Figures are the windows in which MATLAB displays graphics. Figures contain menus, toolbars, user-interface objects, context menus, axes and, as axes children, all other types of graphics objects.

MATLAB places no limits on the number of figures you can create (your computer systems might impose limitations, however).

Figures play two distinct roles in MATLAB:

Figures can contain both graphs and GUIs components at the same time. For example, a GUI might be designed to plot data and therefore contain an axes as well as user interface objects. See Example -- Using Figure Panels for an example of such a GUI.

The following diagram illustrates the types of objects that figures can contain.

Note that both figures and axes have children that act as containers. A uipanel can contain user interface objects and be parented to a figure and group objects (hggroup and hgtransform) can contain axes children and be parented to an axes.

See Objects That Can Contain Other Objects for more information.

Figures Used for Graphing Data

MATLAB functions that draw graphics (e.g., plot and surf) create figures automatically if none exist. If there are multiple figures open, one figure is always designated as the "current" figure, and is the target for graphics output.

The gcf command returns the handle of the current figure or creates a new figure if one does not exist. For example, you can enter the following command to see a list of figure properties.

The root object CurrentFigure property returns the handle of the current figure, if one exists, or returns empty if there are no figures open. For example,

See Controlling Graphics Output for more information on how MATLAB determines where to display graphics.

Figure Children for Graphs

Figures that display graphs need to contain axes to provide the frame of reference for objects such as lines and surfaces, which are used to represent data. These data representing objects can be contained in group objects or contained directly in the axes. See Example -- Translating Grouped Objects for an example of how to use group objects.

Figures can contain multiple axes arranged in various locations within the figure and can be of various sizes. See Automatic Axes Resize and Multiple Axes per Figure for more information on axes.

Figures Used for GUIs

GUIs range from sophisticated applications to simple warning dialog boxes. You can modify many aspects of the figure to fit the intended use by setting figure properties. For example, the following figure properties are often useful when creating GUIs.

See the figure properties for more information on figure characteristics you can specify.

See the Creating Graphical User Interfaces documentation for more information about using figure to create GUIs.

Root Object -- the Figure Parent

The parent of a figure is the root object. You cannot instantiate the root object because its purpose is only to store information. It maintains information on the state of MATLAB, your computer system, and some MATLAB defaults.

There is only one root object and all other objects are its descendants. You do not create the root object; it exists when you start MATLAB. You can, however, set the values of root properties and thereby affect the graphics display.

For more information see root object properties.

More Information on Figures

See the figure reference page for information on creating figures.

See Callback Properties for Graphics Objects for information on figure events for which you can define callbacks.

See Figure Properties for information on other figure properties.


Previous page  Types of Graphics Objects Core Graphics Objects Next page

© 1994-2005 The MathWorks, Inc.