Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Graphics Windows — the Figure

Introduction

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:

  • Containing data graphs

  • Containing graphical user interfaces

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.

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

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 (except light objects) and be parented to an axes.

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, enter the following command to see a list of figure properties:

get(gcf)

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

get(0,'CurrentFigure')
ans =
[]

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 Transforming a Hierarchy of 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 Display Data Using Different Scalings for more information on axes.

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 Properties object properties.

    Note:   The handle of the root object is always 0 (the number zero).

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 Windows for other figure window functionality.

Was this topic helpful?