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({
    'on_time_pct': np.clip(rng.normal(92, 2.5, 24), 80, 100).round(1),
})

# No time column: the values are charted in the order received
study = ProcessBehavior(df).formulate(response='on_time_pct')
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.211, 'upl': 100.556}
{'N': 2, 'center': 3.261, 'lpl': 0.0, 'upl': 10.654}

With no time column the rows are numbered 1..N in an Observation column, in the order received. If your data carries its own order (a week column, a timestamp), name it and the points are charted in that order instead:

study = ProcessBehavior(df).formulate(response='on_time_pct', time='week')

Reading it

Going further