How to control a plot with checkbox in app designer. So when checkbox is tick it may plot graph and when checkbox is unchecked it should remove graph in UIAxes.

21 views (last 30 days)
i m plotting a graph in app designer on UIAxes
a = [1 2 3] % added to property
b = [4 5 6] % added to property
in checkbox call back in write following code
Value = app.checkbox.Value
Value = plot(app.UIAxes,a,b)
now when i run the code and tick the checkbox it successfully plots the graph on UIAxes but when i uncheck it Graph doesnt disappear it remains plotted. kindy guide. Thanks

Accepted Answer

Ameer Hamza
Ameer Hamza on 6 Oct 2020
Check the attached app for the demo.
  4 Comments
義典 鈴木
義典 鈴木 on 6 Dec 2021
Hi. I have a question here. What if I want to create an app like this but I have two separates data. I want my app to be able to plot the first graph of the first data, second graph of the second data and lastly be able to plot both of the data simulataneously. Thank you
義典 鈴木
義典 鈴木 on 6 Dec 2021
I tried to make it like this but it did not work out
properties (Access = private)
a = [1 2 3] % x position
b = [4 5 6] % y position
p % line object
x = [7 8 9]
y = [1 2 3]
s
end
app.p = plot(app.UIAxes, app.a, app.b);
app.p.Visible = 'off';
app.s = plot(app.UIAxes, app.x, app.y);
app.s.Visible = 'off';
value = app.ShowCheckBox.Value;
value2 = app.Show2CheckBox.Value;
if value == 1
app.p.Visible = 'on';
app.s.Visible = 'off';
elseif value2 == 1
app.s.Visible = 'on';
app.p.Visible = 'off';
elseif value == 1 && value2== 1
app.p.Visible = 'on';
app.s.Visible = 'on';
else
app.p.Visible = 'off';
app.s.Visible = 'off';
end

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer 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!