Manage estimates and uncertainty with an interval dot plot

中級

6.7.21

Manage estimates and uncertainty with an interval dot plot

Last updated 2020-01-21 Read time 1 min

In A/B tests or regression results, showing confidence intervals along with point estimates makes conclusions more persuasive. Interval dot plots are clean and easy to read.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import numpy as np
import matplotlib.pyplot as plt

segments = ["Free", "Light", "Standard", "Premium"]
effect = np.array([0.12, 0.18, 0.27, 0.35])
low = effect - np.array([0.05, 0.06, 0.07, 0.08])
high = effect + np.array([0.05, 0.06, 0.07, 0.09])

fig, ax = plt.subplots(figsize=(6.4, 3.6))
ax.hlines(range(len(segments)), low, high, color="#94a3b8", linewidth=3)
ax.scatter(effect, range(len(segments)), color="#0ea5e9", s=90, zorder=3)

ax.axvline(0, color="#475569", linestyle="--", linewidth=1)
ax.set_yticks(range(len(segments)), labels=segments)
ax.set_xlabel("Lift vs control")
ax.set_title("Estimated effects with 90% confidence intervals")
ax.set_xlim(-0.05, 0.45)
ax.grid(axis="x", alpha=0.2)

for idx, (eff, lo, hi) in enumerate(zip(effect, low, high)):
    ax.text(hi + 0.01, idx, f"{eff*100:.1f}% (+{(hi - eff)*100:.1f}/-{(eff - lo)*100:.1f})", va="center")

fig.tight_layout()

plt.show()

Interval dot plots make uncertainty easy to read.

Reading tips #

  • The length of the horizontal line shows uncertainty; shorter lines mean more stable estimates.
  • Use the zero line to judge whether effects cross 0 at a glance.
  • Vary dot size to represent weight or sample size if needed.
  • Dumbbell Chart — Emphasize differences between two time points with lines and dots