This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Class: LinearModel

Scatter plot or added variable plot of linear model


h = plot(mdl)


plot(mdl) creates a plot of the full, fitted linear model, mdl. The plot type depends on the number of predictor variables.

  • If there is just one predictor variable, plot creates a scatter plot of the data along with a fitted curve and confidence bounds.

  • If there are multiple predictor variables, plot creates an added variable plot.

  • If there are no predictors, plot creates a histogram of the residuals.

h = plot(mdl) returns handles to the lines in the plot.

Input Arguments

expand all

Full, fitted linear regression model, specified as a LinearModel object constructed using fitlm or stepwiselm.

Output Arguments

expand all

Graphics handles, returned as a vector of graphics handles corresponding to the lines or patches in the plot.


expand all

Create a model of car mileage as a function of weight and model year. Then create a plot to see the significance of the model.

Create a linear model of mileage from the carsmall data.

load carsmall
tbl = table(MPG,Weight);
tbl.Year = ordinal(Model_Year);
mdl = fitlm(tbl,'MPG ~ Year + Weight^2');

Create an added variable plot.


The plot illustrates that the model is significant because a horizontal line does not fit between the confidence bounds.

More About

expand all


Use plotAdded to select particular predictors for an added variable plot.