The types of charts your app can support depend largely on the kind of figure that underlies the UI. Apps you create using GUIDE, and those apps you create programmatically with uicontrols, use traditional figures and axes. These apps support all the graphics functionality available in MATLAB®.
Apps you create using App Designer are based on a new kind of figure, called a UI figure. To display graphics in these apps, you must use a new type of axes object, called UI axes.
UI figures and UI axes are similar to traditional figures and axes, but there are some important differences to be aware of when deciding how to build your app.
If you are creating an app in App Designer that displays graphics,
you must specify the target UI figure or UI axes when you call certain
graphics functions. If you omit the target object when calling these
functions, MATLAB assumes gcf or gca is
the target object. However, gcf and gca cannot
return UI figures and UI axes, so omitting them might lead to unexpected
results.
Furthermore, UI figures do not support most of the interactive functionality that traditional figures support. For example, UI figures do not support printing, nor do they support panning, zooming, mouse, or keyboard interactions.
The following table lists the graphics functions that UI figures and UI axes support. All other graphics functions are unsupported.
| Category | Functions Supported in R2016a and later | Additional Functions Supported in R2016b | Notes |
|---|---|---|---|
| Charting Functions and Graphics Objects | alphacolormapholdlineplotscattertexttitle | alphamapanimatedlineareabarbarhcaxiscolorbarcontourcontourferrorbarfeatherfcontourfimplicitfplothistogramimageimagescimshowlegendloglogquiverrectanglesemilogxsemilogystairsstemyyaxis | You must specify the target UI figure or UI axes when
you call these functions. Otherwise, MATLAB assumes This code shows how to plot two lines in App
Designer using the plot(app.UIAxes,[1 2 3 4],'-r'); hold(app.UIAxes); plot(app.UIAxes,[10 9 4 7],'--b'); Some
functions (such as imshow('peppers.png','Parent',app.UIAxes); |
| Coordinate Systems | boxgridxlimylimxlabelylabel | datetickxticksyticksxtickangleytickanglextickformatytickformatxticklabelsyticklabels | Specify the UI axes as the target axes when using these functions. For example, this code shows how to set the x-label on a plot in App Designer: xlabel(app.UIAxes,'Frequency'); |
| Utilities | ancestorcladeletegetsetfindobjishandleisgraphicsnewplotreset | pbaspect (2-D) | You might need to specify the UI figure or the UI axes
as the target object when using some these functions. For example,
this code shows how to find a UI axes object in the figure, ax = findobj(app.UIFigure,'XLim',[0 1]); |
| Figures | close | Specify the UI figure as the target figure. For example: f = uifigure; close(f); | |
All other graphics functions are not supported in App Designer, UI figures, and UI axes. | |||
If you are moving code you wrote in previous releases into App Designer, you might encounter these limitations:
UI figures support only a subset of the properties that traditional figures support. For example, UI figures do not support properties for printing, saving, callback execution, or custom mouse and keyboard interaction. For a full list of supported properties, see UI Figure (App Designer) Properties.
UI axes support only a subset of the properties that traditional axes support. For example, UI axes do not support lighting and camera properties or properties for interactive control. For a full list of supported properties, see UI Axes (App Designer) Properties.
UI figures support a different set of interactive components than traditional figures do. For example, UI figures do not support uicontrols or uimenus. For a full list of supported components, see Components in App Designer.
Some components support only a subset of properties
when you place them in UI figures. For example, tables do not support
the Extent property in UI figures. For a list
of supported properties for a particular component, see the component's
property page on the Components in App Designer page.
UI Axes (App Designer) Properties | UI Figure (App Designer) Properties