# Plot the Distribution of Stock Returns in Python (Histogram, Fat Tails, VaR)

> Plot a stock returns histogram in Python with seaborn, overlay a fitted normal distribution, show fat tails on a log axis and mark historical Value at Risk and expected shortfall.

Source: https://www.pythoncharts.com/python/stock-returns-distribution-python/ | Published: 2026-12-05 | Author: Alex Scott | Category: Python | Tags: returns, histogram, distribution, fat-tails, value-at-risk, stock, financial-chart, seaborn, scipy

To plot the distribution of stock returns in Python, compute daily returns with `price.pct_change()` (or `np.log(price).diff()`), draw a density histogram with `sns.histplot(returns, stat="density")`, and overlay a normal curve with `scipy.stats.norm.pdf()` using the sample mean and standard deviation. The histogram shows what a normal curve hides: real returns have more extreme days than a bell curve predicts. For a deeper normality check, see [QQ Plot in Python](https://www.pythoncharts.com/python/qq-plot-python/).

## Quick Example

The prices are simulated (10 years, about 2,500 trading days) from a GARCH(1,1) model with Student-t shocks, which is a standard way to produce returns with volatility clustering and fat tails. Replace `price` with your own adjusted close prices.

```python
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from scipy import stats

rng = np.random.default_rng(8)
n = 2520
shocks = rng.standard_t(6, n) / np.sqrt(1.5)         # unit-variance Student-t, 6 degrees of freedom
r = np.empty(n)
var = 0.0001
for i in range(n):                                    # GARCH(1,1): volatility clusters
    r[i] = 0.0002 + np.sqrt(var) * shocks[i]
    var = 0.000002 + 0.08 * (r[i] - 0.0002) ** 2 + 0.90 * var
price = pd.Series(100 * np.exp(np.cumsum(r)), index=pd.bdate_range("2016-12-01", periods=n), name="Close")

returns = price.pct_change().dropna()
mu, sigma = returns.mean(), returns.std()

fig, ax = plt.subplots(figsize=(10, 5.5))
sns.histplot(returns, bins=80, stat="density", color="#6a4c93", edgecolor="white", ax=ax)
x = np.linspace(returns.min(), returns.max(), 400)
ax.plot(x, stats.norm.pdf(x, mu, sigma), color="#f4a259", lw=2.2, label=f"Normal fit (sd {sigma:.2%})")
ax.set_xlabel("Daily return")
ax.xaxis.set_major_formatter("{x:.1%}")
ax.legend()
plt.show()
```

![Histogram of daily stock returns with a fitted normal curve; the histogram has a taller, narrower peak than the curve](https://www.pythoncharts.com/python/stock-returns-distribution-python/images/returns-quick-example.png)

Daily returns here have a standard deviation of 1.13%, and the histogram is far more peaked than the normal curve fitted to it. About 51% of days fall within half a standard deviation of the mean, against 38% for a normal distribution. The other side of a tall peak is heavy tails, which the next sections measure. The sample mean is about −0.003% a day, so the center sits at 0%.

## How many extreme days are there compared with a normal distribution?

Count the days beyond a threshold of standard deviations and compare with what a normal distribution predicts, using `stats.norm.sf()` (the survival function, one minus the CDF). Excess kurtosis (`returns.kurt()`, 0 for a normal distribution) and skewness (`returns.skew()`) summarize the shape in one number each:

```python
z = (returns - mu) / sigma
rows = []
for k in (2, 3, 4):
    actual = int((z.abs() > k).sum())
    expected = 2 * stats.norm.sf(k) * len(z)
    rows.append({"threshold": f"beyond {k} sd", "actual days": actual, "normal predicts": round(expected, 1)})
print(pd.DataFrame(rows).to_string(index=False))
print(f"skew {returns.skew():.2f}, excess kurtosis {returns.kurt():.2f}")
print(f"worst day {returns.min():.2%} on {returns.idxmin():%Y-%m-%d} ({z.min():.1f} sd)")
```

```text
  threshold  actual days  normal predicts
beyond 2 sd          121            114.6
beyond 3 sd           49              6.8
beyond 4 sd           19              0.2
skew -0.37, excess kurtosis 6.88
worst day -8.37% on 2024-02-09 (-7.4 sd)
```

Two standard deviations is where a normal curve is closest to the data (121 days against 115 predicted). Further out they diverge: there are 49 days beyond three standard deviations where a normal distribution predicts about 7, and 19 beyond four where it predicts 0.2. The excess kurtosis of 6.88 says the same thing in one number, and the skew of −0.37 means the big moves lean toward losses. The worst day, −8.37%, is 7.4 standard deviations from the mean, which a normal distribution treats as practically impossible.

## How do I show the fat tails on a log scale?

On a linear axis the tails are too small to see. Put the density on a log y-axis (`ax.set_yscale("log")`) and the tails, where the normal curve falls away much faster than the data, are the whole story:

```python
fig, ax = plt.subplots(figsize=(10, 5.5))
ax.hist(returns, bins=80, density=True, color="#6a4c93", edgecolor="white", label="Daily returns")
ax.plot(x, stats.norm.pdf(x, mu, sigma), color="#f4a259", lw=2.2, label="Normal fit")
ax.set_yscale("log")
ax.set_ylim(bottom=0.05)
ax.set_xlabel("Daily return")
ax.xaxis.set_major_formatter("{x:.1%}")
ax.set_ylabel("Density (log scale)")
ax.legend()
plt.show()
```

![Histogram of daily returns on a log y-axis with a normal curve that drops to nothing in the tails while the histogram bars continue](https://www.pythoncharts.com/python/stock-returns-distribution-python/images/returns-log-tails.png)

The normal curve drops off the bottom of the chart somewhere between 3% and 4% on either side, but the data keeps going: the largest daily moves are −8.4% and +8.4%. Each bar out there is one or two days. Read the log chart for the shape of the tails, not their exact height, because bars with one observation are noisy.

## How do I mark Value at Risk on the histogram?

Historical Value at Risk (VaR) at 95% is the 5th percentile of returns: on 95% of days the loss was smaller than this. Expected shortfall (also called CVaR) is the average return on the days worse than the VaR. Both come straight from the data, with `returns.quantile(0.05)` and a boolean mask:

```python
var_95 = returns.quantile(0.05)
es_95 = returns[returns <= var_95].mean()
for q in (0.05, 0.01):
    print(f"{1 - q:.0%} VaR: historical {returns.quantile(q):.2%}, normal {stats.norm.ppf(q, mu, sigma):.2%}")

fig, ax = plt.subplots(figsize=(10, 5.5))
counts, edges, patches = ax.hist(returns, bins=80, color="#6a4c93", edgecolor="white")
for left, patch in zip(edges[:-1], patches):
    if left < var_95:
        patch.set_facecolor("#c0392b")
ax.axvline(var_95, color="#c0392b", lw=1.5, ls="--", label=f"95% VaR: {var_95:.2%}")
ax.axvline(es_95, color="#222222", lw=1.5, ls=":", label=f"Expected shortfall: {es_95:.2%}")
ax.set_xlabel("Daily return")
ax.xaxis.set_major_formatter("{x:.1%}")
ax.set_ylabel("Number of days")
ax.legend(loc="upper left")
plt.show()
```

![Histogram of daily returns with the worst 5 percent of days in red, a dashed line at the 95 percent Value at Risk and a dotted line at expected shortfall](https://www.pythoncharts.com/python/stock-returns-distribution-python/images/returns-var.png)

The 95% VaR is −1.67%, so on 5% of days (126 of 2,519) the stock fell by more than that. On those days the average loss was −2.77%, the expected shortfall.

The comparison with a normal distribution flips depending on the confidence level. The code above prints both:

```text
95% VaR: historical -1.67%, normal -1.86%
99% VaR: historical -3.56%, normal -2.64%
```

At 95% the normal distribution slightly overstates the loss, because the data have a taller peak. At 99% it understates it by about a quarter (−2.64% against −3.56%), because the tails are heavier. A VaR calculated from the normal formula is therefore most misleading exactly where it matters most.

## Do longer holding periods look more normal?

Log returns add up over time, so a weekly or monthly return is the sum of daily ones. Sums of many fat-tailed values drift toward a bell curve (the central limit theorem), so tails matter less over long horizons. With log returns, `resample().sum()` does the aggregation:

```python
log_returns = np.log(price).diff().dropna()
horizons = {"Daily": log_returns, "Weekly": log_returns.resample("W").sum(), "Monthly": log_returns.resample("ME").sum()}

fig, axes = plt.subplots(1, 3, figsize=(12, 3.8))
for ax, (name, s) in zip(axes, horizons.items()):
    sns.histplot(s, bins=40, stat="density", color="#6a4c93", edgecolor="white", ax=ax)
    grid = np.linspace(s.min(), s.max(), 300)
    ax.plot(grid, stats.norm.pdf(grid, s.mean(), s.std()), color="#f4a259", lw=2)
    ax.set_title(f"{name} (excess kurtosis {s.kurt():.1f})")
    ax.set_xlabel("Log return")
    ax.xaxis.set_major_formatter("{x:.1%}")
    ax.locator_params(axis="x", nbins=5)
    ax.set_ylabel("")
plt.tight_layout()
plt.show()
```

![Three histograms of daily, weekly and monthly log returns with normal curves; the peak and tails are closest to the curve for monthly returns](https://www.pythoncharts.com/python/stock-returns-distribution-python/images/returns-horizons.png)

Excess kurtosis falls from 7.14 for daily returns to 2.48 for weekly returns, and the weekly histogram follows the curve much more closely. Monthly is 2.59, not lower. With only 116 months in ten years, two very bad months (log returns of −19% and −17%) dominate that number, so a longer history would be needed to see the trend continue. Aggregation moves the distribution toward normal, as the central limit theorem predicts, but volatility clustering makes it slower than it would be for independent returns.

## Simple returns or log returns?

| | Simple return `pct_change()` | Log return `np.log(price).diff()` |
|---|---|---|
| Formula | `P_t / P_(t-1) - 1` | `ln(P_t / P_(t-1))` |
| Adds across time | No (compound them) | Yes (`sum()` gives the period return) |
| Adds across assets in a portfolio | Yes | No |
| Use for | Portfolio weights, reporting a day's gain | Statistics over time, volatility, histograms |

For daily data the two are nearly identical, so the histogram looks the same either way.

## Practical Tips

- **Use adjusted close prices** so splits and dividends do not appear as huge one-day returns.
- **Plot in percent,** `ax.xaxis.set_major_formatter("{x:.1%}")`, so readers do not have to convert 0.02 in their heads.
- **Check the tails with a log axis or a QQ plot,** not just the center. A histogram on a linear axis always looks close to normal.
- **Historical VaR depends on the window.** A calm year gives a small VaR. Compare windows before trusting one number.
- **Normal-based risk numbers understate tail risk** when the data have positive excess kurtosis, as shown above.

## Similar Topics

- [QQ Plot in Python](https://www.pythoncharts.com/python/qq-plot-python/)
- [Bollinger Bands and Moving Averages in Python with pandas](https://www.pythoncharts.com/python/bollinger-bands-python/)
- [Seaborn histplot and displot](https://www.pythoncharts.com/seaborn/seaborn-histplot-displot/)
