I want to put multiple plots on a graph but be able to turn on and off the visibility for a few plots
조회 수: 8 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Kevin Holly
2022년 12월 2일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!