MATLAB Creating Graphical User Interfaces

(ff) #1

Displaying Plots Using Other Types of Axes


You can create most 2-D and 3-D plots using the App Designer axes (a uiaxes object).
Starting in R2018b, you can create additional plots, such as those listed in the following
table. Most of these plots require a different type of parent object and additional lines of
code in your app. All of them use normalized units by default.


Functions Coding Details
polarplot
polarhistogram
polarscatter
compass

Create the polar axes by calling the polaraxes function. Specify
the parent container as the first input argument (for example,
app.UIFigure). Then call the plotting function with the polar
axes as the first argument. For example:

theta = 0:0.01:2*pi;
rho = sin(2*theta).*cos(2*theta);
pax = polaraxes(app.UIFigure);
polarplot(pax,theta,rho)
subplot Follow these steps:

1 Set the AutoResizeChildren property to 'off'. Subplots
do not support automatic resize behavior. You can set this
property in the App Designer Inspector tab of the
Component Browser or in your code.
2 Specify the parent container using the 'Parent' name-value
pair argument when you call subplot. Also, specify an output
argument to store the axes.
3 Call the plotting function with the axes as the first input
argument.

For example:

app.UIFigure.AutoResizeChildren = 'off';
ax1 = subplot(1,2,1,'Parent',app.UIFigure);
ax2 = subplot(1,2,2,'Parent',app.UIFigure);
plot(ax1,[1 2 3 4])
plot(ax2,[10 9 4 7])

Displaying Graphics in App Designer
Free download pdf