Skip to content
svgmethod-comparison

Method comparison

Do two measurement methods agree, or is there constant or proportional bias?

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

How to read it

  1. Read the points as paired measurements.
  2. Compare the solid fit line with the dashed identity line.
  3. An intercept away from zero suggests constant bias; a slope away from 1, proportional bias.
  1. Callout 1: Fit line: how one method tracks the other.
  2. Callout 2: Identity line: perfect agreement.
  3. Callout 3: The fitted equation.

Watch out

  • A high correlation doesn't mean agreement: two methods can correlate perfectly and still differ.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Draws the engine's numbers as given (precomputed by the Python or R analysis); the chart computes nothing inferential.
  • Both axes share one scale so the identity line is the diagonal.
  • The band joins the lines (upper slope, lower intercept) and (lower slope, upper intercept) — Passing–Bablok's slope and intercept limits move together, pivoting near the data's centre.
  • Linearity (the CUSUM test) and the fit's p-values are on the result card.
# Method comparison — Codesplash Chart Lab (recipe "method-comparison")
# 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("method-comparison-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")
def first(col):
    """The first finite value of a column the engine repeats on every row (None if absent)."""
    if col is None:
        return None
    v = pd.to_numeric(df[col], errors="coerce").dropna()
    return float(v.iloc[0]) if len(v) else None
X = "laboratory"
Y = "meter"
B = "slope"
A = "intercept"
BL = "slope low"
BH = "slope high"
AL = "intercept low"
AH = "intercept high"
d = df.dropna(subset=[X, Y])
lim = np.array([min(d[X].min(), d[Y].min()), max(d[X].max(), d[Y].max())])
b, a, bl, bh, al, ah = (first(k) for k in (B, A, BL, BH, AL, AH))
fig, ax = plt.subplots(figsize=(6, 6))
ax.plot(lim, lim, color=REF, linestyle="--", label="identity")
if None not in (bl, bh, al, ah):  # slope limits move with the opposite intercept limits
    ax.fill_between(lim, al + bh * lim, ah + bl * lim, color=PALETTE[0], alpha=0.1, lw=0, label="slope CI limits")
ax.scatter(d[X], d[Y], s=14, color=GREY, edgecolors=REF, linewidths=0.3)
if b is not None and a is not None:
    ax.plot(lim, a + b * lim, color=PALETTE[0], linewidth=2, label=f"y = {a:.3g} + {b:.3g}·x")
ax.set_xlim(*lim)
ax.set_ylim(*lim)
ax.set_aspect("equal")
ax.set_xlabel(X)
ax.set_ylabel(Y)
ax.legend(fontsize=8)
plt.show()

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