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.

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

采纳的回答

Ameer Hamza
Ameer Hamza 2020-10-6
Check the attached app for the demo.
  4 个评论
義典 鈴木
義典 鈴木 2021-12-6
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
義典 鈴木
義典 鈴木 2021-12-6
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by