Create figure for designing apps in App Designer



f = uifigure creates a figure for building a user interface and returns the Figure object. This is the type of figure that App Designer uses.


f = uifigure(Name,Value) specifies figure properties using one or more Name,Value pair arguments.


collapse all

f = uifigure;

Create a UI figure with a specific title.

f= uifigure('Name','Plotted Results');

Get the Position property value.

p = f.Position
ans =

   680   678   560   420

Code the CloseRequestFcn callback to open a modal Confirmation dialog box when the user tries to close the window.

Copy and paste this code into the MATLAB® Editor, and then run closeFig.

function closeFig
f = uifigure('Position',[100 100 350 275],...
    'CloseRequestFcn',@(f, event)my_closereq(f));
function my_closereq(f)
selection = questdlg('Close the figure window?',...
switch selection,
    case 'Yes',
    case 'No'

Click the figure close button. The Confirmation dialog box opens.

Input Arguments

collapse all

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Name','My App' specifies My App as the title of the UI figure.

The properties listed here are a subset of the available properties. For the full list, see UI Figure Properties.

Name of the figure, specified as a character vector or a string scalar.

Example: uifigure('Name','Results') sets the name of the figure to 'Results'.

Location and size of the UI figure, excluding borders and title bar, specified as a four-element vector of the form [left bottom width height].

This table describes each element in the vector.

leftDistance from the left edge of the primary display to the inner left edge of the UI figure window. This value can be negative on systems that have more than one monitor.
bottomDistance from the bottom edge of the primary display to the inner bottom edge of the UI figure window. This value can be negative on systems that have more than one monitor.
widthDistance between the right and left inner edges of the UI figure.
heightDistance between the top and bottom inner edges of the UI figure.


  • Currently, you cannot pass a Figure object created with the uifigure function to the print, rotate3d, pan, or zoom functions. If you attempt to do so, MATLAB throws an error. To use the pan, zoom, and rotate3d interactions for plots you create in uifigure, specify the axes as the first argument, and specify 'on', 'off', or a scale factor (for zoom) as the second argument. For more information, see Displaying Graphics in App Designer.

Introduced in R2016a