Now try:
set(handles.axes1, 'NextPlot', 'add');
handles.handle_plot1 = plot(X1,Y1,'visible','off','LineWidth',2, ...
'color', [0 0 0],'linestyle', '--', 'parent', handles.axes1);
handles.handle_plot2 = plot(X2,Y2,'visible','off','LineWidth',2, ...
'color', [1 0 0],'linestyle', '--', 'parent', handles.axes1);
guidata(hObject, handles);
By the way: I use a specific function to create the 'on', 'off' dynamically:
function S = OnOffStr(D)
OffOn = {'off', 'on'};
L = (D ~= 0) + 1;
if length(L) == 1
S = OffOn{L};
else
S = OffOn(L);
end
Then the callback looks like:
function checkbox1_Callback(hObject, eventdata, handles)
set(handles.handle_plot1, 'Visible', OnOffStr(get(hObject,'Value')));
Best Answer