I want to put multiple plots on a graph but be able to turn on and off the visibility for a few plots
2 views (last 30 days)
Show older comments
I have a graph with a few different plots on (circles,lines,points). I want to be able to have those plots hidden or shown-depending on a switch. Right now i have a switch
function switchValueChanged(app,event)
value = app.Switch.Value;
if strcnp(value,'On')
y=x+1;
plot(app.UIaxis,x,y);
end
end
0 Comments
Answers (1)
Kevin Holly
on 2 Dec 2022
Create a property variable
properties
p
end
Define that property value (do so in startup function or in callback function - whichever is applicable to your application)
y=x+1;
app.p = plot(app.UIaxis,x,y);
Toggle visibility of the plot
function switchValueChanged(app,event)
if strcnp(app.Switch.Value,'On')
app.p.Visible = "on"
else
app.p.Visible = "off"
end
end
0 Comments
See Also
Categories
Find more on Migrate GUIDE 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!