How to Turn off th yyaxis mode in app designer?

5 views (last 30 days)
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

Accepted Answer

M Afshari
M Afshari on 18 Aug 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 Comment
dpb
dpb on 18 Aug 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.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!