figure-Based Apps to Use
MATLAB® provides two functions to create a figure window:
uifigure. While both of these functions create a
Figure object, there are some differences in the way that this object is
configured and the capabilities it supports. Figures created using the
uifigure function are configured primarily for app building, whereas
figures created using the
figure function are configured primarily for
data exploration and visualization.
uifigure function is the recommended function to use when
building new apps programmatically, and is the function that App Designer uses to create apps.
figure function will continue to be supported, but there are many new
app building capabilities that can be used only with UI figures. This page provides an
overview of the differences between
Figure objects created using the
figure function and the
uifigure function, and
information about how to update your app to take advantage of the
uifigure-based app building capabilities.
Overview for Updating Your App
To update your
figure-based app to use
uifigure and take advantage of the additional capabilities in UI
figures, follow these steps:
Update App Figure and Containers — Replace calls to
uifigure, and update the properties of the
Figureobject and other app containers, such as
Update UIControl Objects and Callbacks — Replace calls to
uicontrolwith analogous UI component functions, and update component properties and callbacks.
Update Dialog Boxes — Replace calls to dialog box functions such as
warndlgwith dialog box functions configured for app building such as
Capabilities Only Available with UI Figures
Some benefits of updating your app to use the
uifigure function include:
Additional component types — UI figures support additional modern app building components, such as:
Instrumentation components such as gauges and switches
HTML UI components that let you embed third-party visualizations in your app
Modern layout and resize options — UI figures support grid layout managers and component auto-resize behavior as an alternative to manually specifying the
Positionproperty and writing resize code in a
SizeChangedFcncallback. Using these alternatives can greatly simplify app layout code.
Additional capabilities for existing components — Components in UI figures support additional customization options, including:
Making containers scrollable
Styling individual table cells to change the color and font, and to add icons and format text
tablearray data in table UI components
To see a list of all components supported in
see App Building Components.
The major differences between
figure-based apps and
uifigure-based apps are due to differences in the underlying
Figure object configuration and unsupported functionality.
Understanding these differences will help you update your
app to use
Differences in Default Configuration
Because figures created using the
uifigure function are
configured for app building instead of data exploration, there are some differences in the
default configuration of those
Figure objects when compared to figures
created using the
figure function. This table lists the major
|Explanation of Difference
|Menu and toolbar
|The figure window has a default menu and toolbar with common data exploration functionality.
|The UI figure window does not have a default menu and toolbar.
|The functionality that the menu and toolbar provide is less relevant for app
building than for data exploration. You can create your own custom menu and
toolbar for the apps you create by using the
HandleVisibility of the figure is
'on' by default.
HandleVisibility of the UI figure is
'off' by default.
|The value of the
HandleVisibility property controls
whether the figure or the objects it contains can become the current object (for
graphics functions implicitly use
gca to determine the target for operations such as plotting
HandleVisibility of a UI figure is
'off' by default so that functions do not make unwanted
changes to the user interface.
|Resizing the figure window has no effect on the size of controls and
containers such as
Panel objects by default.
|The UI figure has a property named
that is set to
'on' by default. When
'on', MATLAB automatically resizes objects in the UI figure window whenever the
UI figure window is resized. You can set
'off' to disable this resize behavior.
|Resizing UI components when a user resizes a UI figure window enables app use at any window size. The auto-resize behavior in UI figures provides a lightweight default behavior in addition to other resize management options such as grid layout managers.
|Container location, size, and units
TabGroup objects parented to the figure have
Units set to
'normalized' and occupy the
full size of the figure window.
|All containers and UI components parented to the UI figure have a set default location and size, specified in pixel units.
|Using pixel units to manually specify the position of containers and UI
components provides the most control over your app layout. If you want to
automatically resize containers or components based on the size of their parent in
a UI figure, create a grid layout manager using the
Unsupported Functionality in UI Figures
Some functionality that is supported in figures created using the
figure function is not supported in figures created using the
uifigure function. This table lists common scenarios and coding
patterns that require extra steps or manual code changes when updating your apps to use
|Controls created using
|User interface controls created using the
function are not supported in figures created using the
Update your app to use supported UI components. For example, use the
For more information, see Update UIControl Objects and Callbacks.
|Menu and toolbar
|Figures created using the
uifigure function do not have
the option to specify
|Recreate the relevant behavior or design your own custom menu and toolbar by
|Container border properties
Certain options for configuring
|Determine if this functionality is critical to your app before updating your
app to use
uifigure. Consider customizing container borders
using supported properties, such as
|Modal dialog boxes
'modal' option for
waitbar has no effect when
the dialog box is created for a
Replace calls to these functions with dialog box functions such as
For more information, see Update Dialog Boxes.