, 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.)


1d data array

distA scipy.stats or statsmodels distribution

Compare x against dist. 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.


Location parameter for dist


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)


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.

linestr {‘45’, ‘s’, ‘r’, q’} or None

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.

axMatplotlib AxesSubplot instance, optional

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

**plotkwargsadditional matplotlib arguments to be passed to the

plot command.

figMatplotlib figure instance

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

See also



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(as_pandas=False)
>>> data.exog = sm.add_constant(data.exog)
>>> mod_fit = sm.OLS(data.endog, data.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)