Skip to content
svgttt-plot

Total-time-on-test plot

Is the failure rate rising, falling, constant or bathtub-shaped?

Demo data · seed 20261101 · 50 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read x as the share of units failed and y as the share of total running time used by then.
  2. On the dashed diagonal the failure rate is constant, as an exponential lifetime requires.
  3. Bowed above means a rising failure rate (wear-out); bowed below means a falling one (early failures); an S shape suggests a bathtub.
  1. Callout 1: The curve above the diagonal: a rising failure rate.
  2. Callout 2: The diagonal: a constant failure rate.
  3. Callout 3: Which side means what.

Watch out

  • It needs complete lifetimes. Units still running would need a censored version of this plot.
  • With few failures the curve wanders around the diagonal by chance, so check the battery's p-values too.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Normalized spacings D_i = (n − i + 1)(x_(i) − x_(i−1)); the curve is (i/n, Σ_{j≤i} D_j / Σ D_j). Complete lifetimes only.
  • The area statistic is the mean of the interior points, which equals one minus the Gini statistic.
# Total-time-on-test plot — Codesplash Chart Lab (recipe "ttt-plot")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]

df = pd.read_csv("ttt-plot-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV

_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"])  # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"])  # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
V = "hours"
x = np.sort(df[V].dropna().to_numpy(dtype=float))
x = x[x > 0]
n = x.size
d = (n - np.arange(n)) * np.diff(x, prepend=0.0)  # normalized spacings
u = np.concatenate(([0.0], np.arange(1, n + 1) / n))
ttt = np.concatenate(([0.0], np.cumsum(d) / d.sum()))
area = ttt[1:-1].mean()
fig, ax = plt.subplots(figsize=(6, 5))
ax.plot([0, 1], [0, 1], color=REF, linestyle="--", label="exponential (constant hazard)")
ax.plot(u, ttt, color=PALETTE[0], linewidth=1.8, label="TTT curve")
ax.set_xlabel("Share of units failed (i/n)")
ax.set_ylabel("Scaled total time on test")
ax.set_title(f"Scaled total-time-on-test plot: area {area:.3f}", fontsize=10, loc="left")
ax.legend(frameon=False)
plt.show()

Needs pandas, numpy, matplotlib · reads ttt-plot-demo.csv · app theme from the optional codesplash helper