GUI Hold on issue
조회 수: 13 (최근 30일)
이전 댓글 표시
Hello!
I'm trying to create a GUI, in short, i have an issue with one of my pushbutton functions.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global data1
plot(handles.axes1,data1(:,2),data1(:,5));
This works just fine and gives me my plot.
However, i'd like to add a horizontal line in the same plot, so i used this code :
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global data1
plot(handles.axes1,data1(:,2),data1(:,5));
hold on
plot(handles.axes1,[min(data1(:,2)) max(data1(:,2))],[0.2 0.2],'g-');
hold off
Which essentially draws a green line in the plot, when i compile(push the button), only the green line plots and the initial plot doesn't. I cannot figure this out, please help :).
댓글 수: 0
답변 (1개)
Cris LaPierre
2021년 7월 14일
Short answer, in an app, you need to specify the target axes, just like you do in the plot command.
hold(handles.axes1,'on')
plot(handles.axes1,...)
hold(handles.axes1,'off')
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!