Filter löschen
Filter löschen

How to check and unchecked box using plot in GUI

2 Ansichten (letzte 30 Tage)
Gali Musa
Gali Musa am 11 Feb. 2019
Kommentiert: Adam am 11 Feb. 2019
I plotted trend lines after using various calculation. The plot includes 3 trends lines on x y plane and i used checkbox to shw another trend line calculation. I want to remove the last trend line using unchecked box.
the original plot has
axes(handles.axes1)
plot(x_clean,y_clean,'g'); hold on
plot(x,y,'r'); hold on
plot(xxx,yyy,'k'); hold on
xlevel('Hours (hr)')
ylevel('Corr. Power(MW)')
the other plot for checkbox is
axes(handles.axes1)
plot(xx,yy,'m'); hold on
xlevel('Hours (hr)');
ylevel('Corr. Power (MW)')
How can i unchecked this plot
Thank you
  1 Kommentar
Adam
Adam am 11 Feb. 2019
Simplest option is to keep hold of the handles when you plot them, e.g.
handles.hTrend1 = plot( x_clean,y_clean,'g');
...
guidata( hObject, handles )
Then you can simply use
delete( handles.hTrend1 )
in another function.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Kevin Phung
Kevin Phung am 11 Feb. 2019
Bearbeitet: Kevin Phung am 11 Feb. 2019
"How can i unchecked this plot "
axes(handles.axes1)
plot2 = plot(xx,yy,'m'); hold on
xlevel('Hours (hr)');
ylevel('Corr. Power (MW)')
set(plot2,'Tag','p2') % create a tag so that you can find this line elsewhere
Im assuming you have a callback function for checkboxes which essentially plot your trendlines.
You can set it like so:
plot2 = findobj(groot,'Tag','p2')
if CheckBoxHandle.Value == 0;
set(plot2,'Visible','off')
else %when value is 1 (checked)
set(plot2,'Visible','on')
end
*note: this assumes that your line was already plotted
However, if you're looking to just remove the line entirely then just do
delete(plot2)

Weitere Antworten (0)

Kategorien

Mehr zu Graphics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by