I want to put multiple plots on a graph but be able to turn on and off the visibility for a few plots

5 Ansichten (letzte 30 Tage)
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

Antworten (1)

Kevin Holly
Kevin Holly am 2 Dez. 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

Kategorien

Mehr zu Networks finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by