Remove a line from a plot in UIAxes App Designer
显示 更早的评论
Hello Everyone,
I would like to add or remove a line from a UIAxes, using the Switch Button.
When the switch button is on, everything is working and the curve is plotted. But when I switch to off, the line still remains, and it is not removed from the graph.
In the UIAxes toolbar, I have set the Multiple Plots settings in this way:
NextPlot: add; SortMethod: childorder
This is the code I used, but it is not working:
Thank You!!
function SperimentaleSwitchValueChanged(app, event)
value = app.SperimentaleSwitch.Value;
if strcmp(value, 'On')
exp = importdata('...\Sperimentale.txt');
exp_force = exp(:,2);
exp_displ = exp(:,1);
h1 = plot (app.UIAxes, exp_displ, exp_force/1000)
end
if strcmp(value, 'Off')
delete(h1)
end
end
1 个评论
Prajwol Tamrakar
2023-8-9
See app.UIAxes.Children!! Each plot you created will be included here. The latest plot will be included on top. If you have four line plots, you can delete the first one by
delete(app.UIAxes.Children(4))
Similary, to delete the latest plot, use
delete(app.UIAxes.Children(1))
Hope this is helpful!!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!