How do you set the focus to a specific uiaxes
29 views (last 30 days)
Show older comments
James Kirk
on 7 Nov 2018
Commented: Sylvia Ludwig
on 20 Jan 2022
I am designing an app with the new App Designer format and would like to be able to set the focus of my uifigure to draw on a specific set of uiaxes when I activate a particular callback.
When I attempt to target the axis for plotting using
axes(app.UIAxes)
I get the following error:
Error using axes
Functionality not supported with figures created with the uifigure function.
And calling:
uiaxes(app.UIAxes)
yields:
Error using uiaxes (line 32)
UIAxes cannot be a child of UIAxes.
Is it possible to set the current axes/panel of a uifigure object via their handle? How do I go back add a plot to uiaxes after having created them and subsequently edited other components on the uifigure?
0 Comments
Accepted Answer
Cris LaPierre
on 7 Nov 2018
I would recommend using the plot(ax,___) syntax.
" plot(ax,___) creates the line in the axes specified by ax instead of in the current axes (gca). The option ax can precede any of the input argument combinations in the previous syntaxes."
What I typically do is create a startup function that generates the initial plot
function startupFcn(app)
...
app.p1 = plot(app.UIAxes,x,y1)
...
end
Then, when I want to update my line, my app just updates the XData and YData properties of app.p1
% Update line
app.p1.XData = x_new;
app.p1.YData = y1_new;
Of course, this all depends on what type of plot you want to create.
5 Comments
More Answers (0)
See Also
Categories
Find more on Develop uifigure-Based Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!