How to plot Multiple trend-lines on one scatter plot
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi every one,
I have a scatter plot and I need to do a second order trend line for some part of my data (just for the values less than 15 or 10 on x axis). Do you know how can I do that?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/359794/image.jpeg)
0 comentarios
Respuestas (1)
KSSV
el 13 de Sept. de 2020
Editada: KSSV
el 14 de Sept. de 2020
You can pick those respective points and fit a curve to plot the trend. Let x,y be your points.
x1 = x(x<=15) ; % pick points less than 15
y1 = y(x<=15) ;
p1 = polyfit(x1,y1,1) ; % Fit a line
figure
hold on
plot(x,y,'.k')
plot(x1,polyval(p1,x1),'r')
11 comentarios
Ver también
Categorías
Más información sobre Discrete Data Plots 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!