How to Turn off th yyaxis mode in app designer?

in the code followed below, when I switch off, I expect the second y axis delete. But it remains.
cla(app.UIAxes,"reset") is useless because The lables will be cleared.
what is your suggestion?
methods (Access = private)
function [] = ploot(app)
a=[1,2,3,4];
b=2*a;
c=2*b;
plot(app.UIAxes,a,b);
yyaxis(app.UIAxes,'right');
plot(app.UIAxes,a,c);
end
end
% Callbacks that handle component events
methods (Access = private)
% Value changed function: Switch
function SwitchValueChanged(app, event)
value = app.Switch.Value;
switch value
case 'On'
ploot(app);
case 'Off'
cla(app.UIAxes);
end

 Respuesta aceptada

M Afshari
M Afshari el 18 de Ag. de 2022
Actually I think There's no other way but using the cla (app.UIAxes,'reset'), so I must have define the labales in the function again.
cla(app.UIAxes,'reset');
plot(a,b);
ylabel(app.UIAxes,'Y');
yaxis(app.UIAxes,'right');
plot(a,c);
ylabel(app.UIAxes,'Y2');
xlabel(app.UIAxes,'X');

1 comentario

dpb
dpb el 18 de Ag. de 2022
TMW has pretty-much locked down the axes object with the yyaxis stuff so you can't get at as much -- there are two x-axis object handles; one would think one should be able to close/delete one of those, and it would go away, but no!, nothing happens when try that.
I've wished for similar functionality on occasion before, as well; seems like there should be a definable way to revert back to a single axes; whether just left or right.
I've stuck with plotyy on occasion for similar reasons; one still has both axes objects that can mung on to heart's content including deleting one without losing the other. There are warts in keeping the two in synch on occasion that the yyaxis object doesn't have, but it can come with a price as well.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2022a

Preguntada:

el 18 de Ag. de 2022

Comentada:

dpb
el 18 de Ag. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by