How do I change the line color and line width of a graph plotted through a GUI?
51 ビュー (過去 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!