Plot guides › Chart types

Q-Q plot (normality check)

A Q-Q plot compares your data's quantiles with those of a normal distribution. Points on the diagonal mean the data are roughly normal; curves at the ends reveal skew or heavy tails.

Example q-q plot (normality check) made with matplotlib
Rendered from the code below, with example data.

When to use it

Ask for it in pltchat

Upload your file and type something like:

"Q-Q plot of the residuals against a normal distribution"

pltchat writes the loader and the plot for your columns, runs it in your browser and shows you the code.

The matplotlib code

Self-contained with example data; swap in pd.read_csv(...) or pd.read_excel(...) for your own file.

import numpy as np
import matplotlib.pyplot as plt
from statistics import NormalDist

rng = np.random.default_rng(28)
samples = {"Normal": rng.normal(0, 1, 150), "Right-skewed": rng.lognormal(0, 0.6, 150)}

fig, axes = plt.subplots(1, 2, figsize=(7.5, 3.6))
for ax, (name, x) in zip(axes, samples.items()):
    x = np.sort((x - x.mean()) / x.std(ddof=1))
    probs = (np.arange(1, x.size + 1) - 0.5) / x.size
    theo = np.array([NormalDist().inv_cdf(p) for p in probs])
    ax.scatter(theo, x, s=10)
    ax.plot([-3, 3], [-3, 3], color="C1")
    ax.set_title(name)
    ax.set_xlabel("Theoretical quantiles")
axes[0].set_ylabel("Sample quantiles (standardised)")
plt.tight_layout()
plt.show()

Make this with your data

Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.

Related plots