How do I change the line color and line width of a graph plotted through a GUI?
40 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Adam
el 26 de Abr. de 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.
Respuestas (1)
KSSV
el 26 de Abr. de 2017
Read about plot
x = rand(10,1) ;
y = rand(10,1) ;
cs = 'r' ;
n = 2 ;
plot(x,y,'color',cs,'linewidth',n) ;
0 comentarios
Ver también
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!