Products & Services Solutions Academia Support User Community Company

Learn more about Statistics Toolbox   

refline - Add reference line to plot

Syntax

refline(m,b)
refline(coeffs)
refline
hline = refline(...)

Description

refline(m,b) adds a reference line with slope m and intercept b to the current axes.

refline(coeffs), where coeffs is a two-element coefficient vector, adds the line

   y = coeffs(1)*x + coeffs(2) 

to the figure.

refline with no input arguments is equivalent to lsline.

hline = refline(...) returns the handle hline to the line.

Examples

Add a reference line at the mean of a data scatter and its least-squares line:

x = 1:10;

y = x + randn(1,10);
scatter(x,y,25,'b','*')

lsline

mu = mean(y);
hline = refline([0 mu]);
set(hline,'Color','r')

See Also

refcurve, lsline, gline

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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