seaborn.residplot

seaborn.residplot(x, y, data=None, lowess=False, x_partial=None, y_partial=None, order=1, robust=False, dropna=True, label=None, color=None, scatter_kws=None, line_kws=None, ax=None)

Plot the residuals of a linear regression.

This function will regress y on x (possibly as a robust or polynomial regression) and then draw a scatterplot of the residuals. You can optionally fit a lowess smoother to the residual plot, which can help in determining if there is structure to the residuals.

参数:x:vector or string

Data or column name in <cite>data</cite> for the predictor variable.

y:vector or string

Data or column name in <cite>data</cite> for the response variable.

data:DataFrame, optional

DataFrame to use if <cite>x</cite> and <cite>y</cite> are column names.

lowess:boolean, optional

Fit a lowess smoother to the residual scatterplot.

{x, y}_partial:matrix or string(s) , optional

Matrix with same first dimension as <cite>x</cite>, or column name(s) in <cite>data</cite>. These variables are treated as confounding and are removed from the <cite>x</cite> or <cite>y</cite> variables before plotting.

order:int, optional

Order of the polynomial to fit when calculating the residuals.

robust:boolean, optional

Fit a robust linear regression when calculating the residuals.

dropna:boolean, optional

If True, ignore observations with missing data when fitting and plotting.

label:string, optional

Label that will be used in any plot legends.

color:matplotlib color, optional

Color to use for all elements of the plot.

{scatter, line}_kws:dictionaries, optional

Additional keyword arguments passed to scatter() and plot() for drawing the components of the plot.

ax:matplotlib axis, optional

Plot into this axis, otherwise grab the current axis or make a new one if not existing.

返回值:ax:matplotlib axes

Axes with the regression plot.

See also

Plot a simple linear regression model.marginal distrbutions.


书籍推荐