App designer hide/show line graph on axes

13 次查看(过去 30 天)
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!

回答(1 个)

Rik
Rik 2023-4-22
移动:Matt J 2023-4-22
And set(B, 'visible', 'off');?
  2 个评论
Matt
Matt 2023-4-25
编辑:Matt 2023-4-25
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 2023-4-25
You need to store A and B in the properties. How is Matlab supposed to know what you mean with []?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by