App designer hide/show line graph on axes

11 views (last 30 days)
Matt
Matt on 22 Apr 2023
Commented: Rik on 25 Apr 2023
Hi,
For the life of me I cannot hide/show a graph on my axes when I click a checkbox. I've tried something like:
set(app.graph1, 'visible', 'off');
But of course this hides the axes not the data and I want the other way around. I've tried the following:
set(app.graph1.Children, 'visible', 'off');
This hides the axes content but I just want to hide a specific set of data on the axes. For example I had:
A=plot(app.graph1, time2, speed2, '--m');
hold(app.graph1, 'on');
B=plot(app.graph1, time2, power2, '--b');
So really I just want to hide for example B but keep A.
Thanks!

Answers (1)

Rik
Rik on 22 Apr 2023
Moved: Matt J on 22 Apr 2023
And set(B, 'visible', 'off');?
  2 Comments
Matt
Matt on 25 Apr 2023
Edited: Matt on 25 Apr 2023
It doesn't work. Here is the code:
function Dataset1CheckBoxValueChanged(app, event)
value1=app.Dataset1CheckBox.Value;
A=[];
if value1==1
set(A, 'visible', 'on');
set(app.graph1, 'visible', 'on');
app.dataset1=evalin('base', 'dataset1');
time1=app.dataset1(:,5);
power1=app.dataset1(:,10);
power2=app.dataset1(:,13);
A=plot(app.graph1, time1, power1, 'm');
hold(app.graph1, 'on');
B=plot(app.graph1, time1, power2, 'b');
else
set(A, 'visible', 'off');
end
end
Rik
Rik on 25 Apr 2023
You need to store A and B in the properties. How is Matlab supposed to know what you mean with []?

Sign in to comment.

Categories

Find more on Specifying Target for Graphics Output 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!