Remove a line from a plot in UIAxes App Designer
Mostrar comentarios más antiguos
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 comentario
Prajwol Tamrakar
el 9 de Ag. de 2023
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!!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!