To make a Q-Q plot in Python, use scipy.stats.probplot(data, plot=ax) or statsmodels.api.qqplot(data, line="s"). A Q-Q (quantile-quantile) plot puts your sorted data against the values you'd expect from a reference distribution, usually the normal. Points on a straight line mean the data follows that distribution.
Quick Example
This checks whether the fill volume of 150 drink cans looks normally distributed.
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats
rng = np.random.default_rng(14)
fill = rng.normal(loc=355, scale=2.5, size=150) # ml of drink per can
fig, ax = plt.subplots(figsize=(7, 5))
(osm, osr), (slope, intercept, r) = stats.probplot(fill, dist="norm", plot=ax)
ax.get_lines()[0].set(color="#3a5a40", markersize=4)
ax.get_lines()[1].set(color="#bc4749", linewidth=1.5)
ax.set(title="Q-Q plot of can fill volumes", xlabel="Theoretical normal quantiles",
ylabel="Fill volume (ml)")
fig.tight_layout()
plt.show()

probplot() returns the plotted points and a least-squares line. For normal data, the line's slope estimates the standard deviation (2.39 here, against a sample value of 2.37) and its intercept estimates the mean (355.0).
SciPy's documentation calls this a probability plot, because it places the theoretical quantiles slightly differently from statsmodels. You read it the same way.
How to Read a Q-Q Plot
The shape of the departure from the line tells you how the data differs from normal. Each pair below shows a sample's histogram and its Q-Q plot.
import statsmodels.api as sm
rng = np.random.default_rng(3)
n = 300
samples = {
"Normal": rng.normal(size=n),
"Right skew": rng.lognormal(sigma=0.7, size=n),
"Left skew": -rng.lognormal(sigma=0.7, size=n),
"Heavy tails": rng.standard_t(df=3, size=n),
"Light tails": rng.uniform(-1, 1, size=n),
"Two groups": np.concatenate([rng.normal(-2.5, 0.8, n // 2),
rng.normal(2.5, 0.8, n // 2)]),
}
fig, axes = plt.subplots(4, 3, figsize=(10, 10.5),
gridspec_kw={"height_ratios": [1, 2.2, 1, 2.2]})
for i, (name, x) in enumerate(samples.items()):
row, col = 2 * (i // 3), i % 3
hist_ax, qq_ax = axes[row, col], axes[row + 1, col]
hist_ax.hist(x, bins=30, color="#6a4c93")
hist_ax.set_title(name, fontweight="bold")
hist_ax.set_yticks([])
hist_ax.spines[["top", "right", "left"]].set_visible(False)
sm.qqplot(x, line="q", ax=qq_ax, markerfacecolor="#6a4c93",
markeredgecolor="none", markersize=3.5)
qq_ax.get_lines()[1].set_color("black")
qq_ax.set_xlabel("Theoretical quantiles")
qq_ax.set_ylabel("Sample quantiles" if col == 0 else "")
fig.tight_layout()
plt.show()

| Shape of the points | What it means |
|---|---|
| Straight line | Consistent with the reference distribution |
| Both ends above the line (curves up) | Right skew |
| Both ends below the line (curves down) | Left skew |
| Left end below, right end above | Heavy tails: more extreme values than normal |
| Left end above, right end below | Light tails: fewer extreme values than normal |
| Step or jump in the middle | Two or more separate groups |
| One or two points far from an otherwise straight line | Outliers |
The axes are quantiles, so the middle of the plot holds most of the data and the ends hold only a few points each.
statsmodels qqplot Reference Lines
sm.qqplot() draws no line unless you ask for one, and line="45" only makes sense when the data and the reference distribution are on the same scale:
fig, axes = plt.subplots(1, 3, figsize=(11, 3.9))
panels = [("line='45'", dict(line="45")),
("line='45', fit=True", dict(line="45", fit=True)),
("line='s'", dict(line="s"))]
for ax, (title, kwargs) in zip(axes, panels):
sm.qqplot(fill, ax=ax, markersize=3.5, **kwargs)
ax.set_title(title)
fig.tight_layout()
plt.show()

By default the comparison is against a standard normal (mean 0, standard deviation 1), so fill volumes near 355 ml end up far from the 45-degree line.
line= |
Reference line |
|---|---|
"45" |
y = x. Use with fit=True, which standardizes the data first |
"s" |
Scaled by the sample standard deviation and shifted by the mean |
"r" |
Least-squares regression through the points |
"q" |
Through the first and third quartiles, so outliers barely move it |
None (default) |
No line |
Add a Confidence Band to a Q-Q Plot
Even normal data wiggles around the line, especially in small samples. A simulation shows how much wiggle to expect: draw many normal samples of the same size, standardize and sort each one, and shade the middle 95% at every position.
rng = np.random.default_rng(21)
waits = rng.gamma(shape=6, scale=1.5, size=80) # minutes
osm, osr = stats.probplot(waits, fit=False)
z = (osr - waits.mean()) / waits.std(ddof=1)
sims = rng.normal(size=(5000, len(waits)))
sims = (sims - sims.mean(axis=1, keepdims=True)) / sims.std(axis=1, ddof=1, keepdims=True)
sims.sort(axis=1)
low, high = np.percentile(sims, [2.5, 97.5], axis=0)
outside = (z < low) | (z > high)
fig, ax = plt.subplots(figsize=(7, 5.2))
ax.fill_between(osm, low, high, color="#cfe1f2", label="95% pointwise envelope")
ax.plot(osm, osm, color="#4a4a4a", linestyle="--", linewidth=1)
ax.scatter(osm[~outside], z[~outside], s=22, color="#1d4e89", label="Inside")
ax.scatter(osm[outside], z[outside], s=26, color="#e8871e", label="Outside")
ax.set(title="Wait times against a normal distribution",
xlabel="Theoretical quantiles", ylabel="Standardized sample quantiles")
ax.legend(frameon=False)
fig.tight_layout()
plt.show()

Six of the 80 points fall outside the band. The band is pointwise, so a few points outside are expected even for normal data. What matters more here is the pattern at the left end, where the smallest values sit above the band: wait times can't go far below the mean, which is a sign of right skew.
Q-Q Plot Against Other Distributions
Set dist to any scipy.stats distribution. Times between random arrivals are often exponential:
rng = np.random.default_rng(5)
gaps = rng.exponential(scale=4.0, size=200) # minutes between arrivals
fig, axes = plt.subplots(1, 2, figsize=(10, 4.2))
stats.probplot(gaps, dist="norm", plot=axes[0])
axes[0].set_title("Against a normal distribution")
stats.probplot(gaps, dist="expon", plot=axes[1])
axes[1].set_title("Against an exponential distribution")
for ax in axes:
ax.get_lines()[0].set(color="#00798c", markersize=3.5)
ax.get_lines()[1].set(color="black")
fig.tight_layout()
plt.show()

Distributions with shape parameters need them passed in sparams, for example stats.probplot(x, dist="t", sparams=(4,), plot=ax) for a t distribution with 4 degrees of freedom.
Compare Two Samples with a Q-Q Plot
To compare two datasets, plot the quantiles of one against the quantiles of the other. np.quantile() handles samples of different sizes.
rng = np.random.default_rng(9)
old = rng.gamma(shape=4, scale=60, size=500) # page load times in ms
new = rng.gamma(shape=4, scale=48, size=350)
probs = np.linspace(0.01, 0.99, 99)
q_old = np.quantile(old, probs)
q_new = np.quantile(new, probs)
fig, ax = plt.subplots(figsize=(6, 6))
ax.scatter(q_old, q_new, s=20, color="#9d0208")
top = q_old.max() * 1.05
ax.plot([0, top], [0, top], color="gray", linestyle="--", label="Same distribution")
ax.set(xlim=(0, top), ylim=(0, top), aspect="equal",
xlabel="Old page load time quantiles (ms)",
ylabel="New page load time quantiles (ms)")
ax.legend(frameon=False)
fig.tight_layout()
plt.show()

Each percentile from the 1st to the 99th is lower for the new load times. The median fell from 219 ms to 177 ms and the 90th percentile from 396 ms to 334 ms. The gap grows with load time, which points to a proportional speedup. A CDF plot shows the same comparison in terms of the share of loads under each time.
Q-Q Plot or Normality Test?
A test such as stats.shapiro() gives a p-value, but its sensitivity depends on sample size. This sample is only slightly heavier-tailed than normal:
rng = np.random.default_rng(1)
nearly = rng.standard_t(df=12, size=5000)
print(f"p = {stats.shapiro(nearly).pvalue:.1e}")
p = 6.9e-09
With 5,000 points the test rejects normality decisively, although the difference may not matter for your analysis. With small samples the opposite happens, and clearly non-normal data can pass. A Q-Q plot shows how large the departure is and where it occurs, so look at it before relying on a test.
For regression models, apply the same plot to the residuals. See residual plots in Python.