Documentation

Graphics Support in App Designer

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 apps you create programmatically using theuicontrolfunction, 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 aUI figure. To display graphics in these apps, you must use a new type of axes, calledUI 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.

Graphics Support

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. Otherwise, MATLAB assumesgcforgcais the target. However,gcfandgcacannot 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 mouse or keyboard interactions.

The following table lists the graphics functions that UI figures and UI axes support.

Category Supported in R2016a and later Added in R2016b Added in R2017a Notes
Charting Functions and Graphics Objects alpha
colormap
hold
line
plot
scatter
text
title
alphamap
animatedline
area
bar
barh
caxis
colorbar
contour
contourf
errorbar
feather
fcontour
fimplicit
fplot
histogram
image
imagesc
imshow
legend
loglog
quiver
rectangle
semilogx
semilogy
stairs
stem
yyaxis
comet
plot(graph)
triplot
voronoi

You must specify the target UI figure or UI axes when you call these functions.

This code shows how to specify the target UI axes in App Designer:

plot(app.UIAxes,[1 2 3 4],'-r'); hold(app.UIAxes); plot(app.UIAxes,[10 9 4 7],'--b');

Some functions (such asimshowandtriplot) require a name-value pair argument to specify the target. For example, this code shows how to call theimshowfunction in App Designer:

imshow('peppers.png','Parent',app.UIAxes);

Coordinate Systems box
grid
xlim
ylim
xlabel
ylabel
datetick
xticks
yticks
xtickangle
ytickangle
xtickformat
ytickformat
xticklabels
yticklabels

Specify the UI axes as the target when using these functions. For example, this code shows how to set thex-label on a plot in App Designer:

xlabel(app.UIAxes,'Frequency');

Utilities ancestor
cla
delete
get
set
findobj
ishandle
isgraphics
newplot
reset
pbaspect(2-D) alim
drawnow
pan
zoom

You might need to specify the target UI figure or the UI axes when calling some these functions.

This code shows how to find aUIAxesobject in theFigure,app.UIFigure. In this case,findobjsearches for an object whoseXLimproperty is[0 1].

ax = findobj(app.UIFigure,'XLim',[0 1]);

This code shows how to use thepanandzoomfunctions.

pan(app.UIAxes,'on'); zoom(app.UIAxes,'on');
For UI axes,panonly supports the'on'and'off'arguments.zoomonly supports the'on','off', andfactorarguments.

Figures close

Specify the UI figure as the target. For example:

f = uifigure; close(f);

Properties and Component Support

如果你移动代码前relea写道ses 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, seeUI Figure 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, seeUIAxes Properties.

  • UI figures support a different set of interactive components than traditional figures do. For example, UI figures do not support components created with theuicontroloruimenufunctions. For a full list of supported components, seeComponents in App Designer.

  • Some components support only a subset of properties when you place them in UI figures. For example,TableUI components do not support theExtentproperty in UI figures. For a list of supported properties for a particular component, see the component's property page on theComponents in App Designerpage.

See Also

|

Related Topics

Was this topic helpful?