Skip to Main Content Skip to Search
Product Documentation

lsline - Add least-squares line to scatter plot

Syntax

lsline
h = lsline

Description

lsline superimposes a least-squares line on each scatter plot in the current axes. Scatter plots are produced by the MATLAB scatter and plot functions. Data points connected with solid, dashed, or dash-dot lines (LineStyle '-', '--', or '.-') are not considered to be scatter plots by lsline, and are ignored.

h = lsline returns a column vector of handles h to the least-squares lines.

Examples

Use lsline together with scatter plots produced by scatter and various line styles of plot:

x = 1:10;

y1 = x + randn(1,10);
scatter(x,y1,25,'b','*')
hold on

y2 = 2*x + randn(1,10);
plot(x,y2,'mo')

y3 = 3*x + randn(1,10);
plot(x,y3,'rx:')

y4 = 4*x + randn(1,10);
plot(x,y4,'g+--')

lsline

See Also

gline | plot | refcurve | refline | scatter

  


 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS