If you want the checkbox to only control the visibility of a given plot, you need to create your plot before and save the handle of your plot, so you can reuse it later to switch the visibility on or off.
somewhere else in your code:
handles.handle_plot1 = plot(vectorx,vectory);
then in the callback of your checkbox:
function checkbox1_Callback(hObject, eventdata, handles) handles.handle_plot1 = handles.handle_plot1 %// optional, you can use another way to retrieve your handle if (get(hObject,'Value')) == 1 set(handle_plot1, 'visible' , 'on') else set(handle_plot1, 'visible' , 'off') end
Don't forget to save the handle of the plot (just after you created it) in a way you can retrieve it from your callback, but I assume you know how to do that since in your original code your callback was already calling the variable vectorx and vectory.
Obviously, do the same thing for the second plot and checkbox.