Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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 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.

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. 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.

CategoryFunctions Supported in R2016a and laterAdditional Functions Supported in R2016bNotes
Charting Functions and Graphics Objectsalpha
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

You must specify the target UI figure or UI axes when you call these functions. Otherwise, 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.

This code shows how to plot two lines in App Designer using the hold function:

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

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

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

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

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');

Utilitiesancestor
cla
delete
get
set
findobj
ishandle
isgraphics
newplot
reset
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, app.UIFigure. In this case, findobj searches the UI figure for an object whose XLim property is [0 1].

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

Figuresclose 

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.

Properties and Component Support

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.

See Also

|

More About

Was this topic helpful?