Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

XmR Chart in Python

An XmR chart pairs an individuals chart (X — each measurement plotted in time order) with a moving-range chart (mR — the gap between consecutive measurements). It is the right chart whenever you have one measurement per period: weekly KPIs, daily yields, per-batch readings.

The 60-second version

import numpy as np
import pandas as pd
from processbehavior import ProcessBehavior

rng = np.random.default_rng(3)
df = pd.DataFrame({
    'week': range(1, 25),
    'on_time_pct': np.clip(rng.normal(92, 2.5, 24), 80, 100).round(1),
})

study = ProcessBehavior(df).formulate(response='on_time_pct', time='week')
result = study.execute(chart='X', companion=True)

print(result.get_statistics('X'))
print(result.get_statistics('mR'))
result.plot()   # interactive plotly figure: X on top, mR below

Output:

{'N': 1, 'center': 91.883, 'lpl': 83.209, 'upl': 100.557}
{'N': 2, 'center': 3.261, 'lpl': 0.0, 'upl': 10.657}

Reading it

Going further