App designer hide/show line graph on axes

11 visualizaciones (últimos 30 días)
Matt
Matt el 22 de Abr. de 2023
Comentada: Rik el 25 de Abr. de 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!

Respuestas (1)

Rik
Rik el 22 de Abr. de 2023
Movida: Matt J el 22 de Abr. de 2023
And set(B, 'visible', 'off');?
  2 comentarios
Matt
Matt el 25 de Abr. de 2023
Editada: Matt el 25 de Abr. de 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 el 25 de Abr. de 2023
You need to store A and B in the properties. How is Matlab supposed to know what you mean with []?

Iniciar sesión para comentar.

Categorías

Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by