Main Content

Add least-squares line to scatter plot

`lsline`

superimposes a least-squares line on each scatter
plot in the current axes.

`lsline`

ignores data points that are connected with solid,
dashed, or dash-dot lines (`'-'`

, `'--'`

, or
`'.-'`

) because it does not consider them to be scatter plots.
To produce scatter plots, use the MATLAB^{®}
`scatter`

and `plot`

functions.

`lsline(`

superimposes a least-squares
line on the scatter plot in the axes specified by `ax`

)`ax`

instead of
the current axes (`gca`

).

returns a
column vector of least-squares line objects `h`

= lsline(___)`h`

using any of the
previous syntaxes. Use `h`

to modify the properties of a specific
least-squares line after you create it. For a list of properties, see Line Properties.