How do I change the line color and line width of a graph plotted through a GUI?
43 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Adam
am 26 Apr. 2017
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.
Antworten (1)
KSSV
am 26 Apr. 2017
Read about plot
x = rand(10,1) ;
y = rand(10,1) ;
cs = 'r' ;
n = 2 ;
plot(x,y,'color',cs,'linewidth',n) ;
0 Kommentare
Siehe auch
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!