How do I change the line color and line width of a graph plotted through a GUI?
조회 수: 42 (최근 30일)
이전 댓글 표시
So I'm trying to change the line color and line width of a graph plotted in through a GUI I made in matlab, but I'm not sure how to do it.. the code I have for plotting the graph so far is as follows:
% --- Executes on button press in pushbutton_solve.
function pushbutton_solve_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_solve (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a = str2num(get(handles.value_a,'string'));
b = str2num(get(handles.value_b,'string'));
c = str2num(get(handles.value_c,'string'));
x = str2num(get(handles.x_min,'string')):str2num(get(handles.x_increment,'string')):str2num(get(handles.x_max,'string'));
y = a*x.^2 + b*x + c;
axes(handles.axes1);
plot(x,y)
xlabel = ('x-value');
ylabel = ('y-value');
guidata(hOject,handles)
end
댓글 수: 1
Adam
2017년 4월 26일
As an aside to the question, you should use the
plot( handles.axes1, x, y,... )
syntax, with the additions pointed out by KSSV in his answer rather than
axes(handles.axes1);
plot(x,y)
Your version works, but it is much better practice to get used to telling the plot function explicitly which axes to plot on rather than relying on having brought the right axes into focus beforehand.
답변 (1개)
KSSV
2017년 4월 26일
Read about plot
x = rand(10,1) ;
y = rand(10,1) ;
cs = 'r' ;
n = 2 ;
plot(x,y,'color',cs,'linewidth',n) ;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!