, dist=<scipy.stats._continuous_distns.norm_gen object>, distargs=(), a=0, loc=0, scale=1, fit=False, line=None, ax=None, **plotkwargs)[source]

Q-Q plot of the quantiles of x versus the quantiles/ppf of a distribution.

Can take arguments specifying the parameters for dist or fit them automatically. (See fit under Parameters.)


A 1d data array.


Comparison distribution. The default is scipy.stats.distributions.norm (a standard normal).


A tuple of arguments passed to dist to specify it fully so dist.ppf may be called.


Offset for the plotting position of an expected order statistic, for example. The plotting positions are given by (i - a)/(nobs - 2*a + 1) for i in range(0,nobs+1)


Location parameter for dist


Scale parameter for dist


If fit is false, loc, scale, and distargs are passed to the distribution. If fit is True then the parameters for dist are fit automatically using The quantiles are formed from the standardized data, after subtracting the fitted loc and dividing by the fitted scale.

line{None, “45”, “s”, “r”, “q”}

Options for the reference line to which the data is compared:

  • “45” - 45-degree line

  • “s” - standardized line, the expected order statistics are scaled by the standard deviation of the given sample and have the mean added to them

  • “r” - A regression line is fit

  • “q” - A line is fit through the quartiles.

  • None - by default no reference line is added to the plot.

axAxesSubplot, optional

If given, this subplot is used to plot in instead of a new figure being created.


Additional matplotlib arguments to be passed to the plot command.


If ax is None, the created figure. Otherwise the figure to which ax is connected.


Depends on matplotlib. If fit is True then the parameters are fit using the distribution’s fit() method.


>>> import statsmodels.api as sm
>>> from matplotlib import pyplot as plt
>>> data = sm.datasets.longley.load()
>>> exog = sm.add_constant(data.exog)
>>> mod_fit = sm.OLS(data.endog, exog).fit()
>>> res = mod_fit.resid # residuals
>>> fig = sm.qqplot(res)

qqplot of the residuals against quantiles of t-distribution with 4 degrees of freedom:

>>> import scipy.stats as stats
>>> fig = sm.qqplot(res, stats.t, distargs=(4,))

qqplot against same as above, but with mean 3 and std 10:

>>> fig = sm.qqplot(res, stats.t, distargs=(4,), loc=3, scale=10)

Automatically determine parameters for t distribution including the loc and scale:

>>> fig = sm.qqplot(res, stats.t, fit=True, line="45")

The following plot displays some options, follow the link to see the code.

(Source code)


(png, hires.png, pdf)


(png, hires.png, pdf)


(png, hires.png, pdf)


(png, hires.png, pdf)

Last update: Jul 16, 2024