# Q-37: One chart that makes one point

Data-Driven Athletics tutorial · Week 13 · Chapter 13 · about 15 min · workflow steps: Visualize

Web page: https://apopt.com/course/tutorials/q37-one-chart/ · Data: https://apopt.com/data/tutorials/q37-one-chart/

## The decision

The coach has a few seconds to look at the report's chart. Decide what the chart must say on
its own: did the step rate change, against the athlete's own usual range, and did it last?

## The raw data

- `raw/cadence_sessions_synthetic.csv`: SYNTHETIC: 15 clips of a runner's step rate (steps a minute), three per session on days 1, 4, 8, 22 and 29, with the phase of the metronome cue Book example data, Chapter 13 (`book/ch13-coaching/data/cadence_sessions.csv`), a teaching set of the size and spread the running app reports for one runner.

A chart in a report has a few seconds of the reader's attention. Section 13.5 turns the
research on how people read charts into five rules: one message, and it is the title; the
athlete's own baseline as the reference; the single trials as well as the means; meaning that
does not depend on color; and no more digits on the axis than the measurement supports.

The data are Chapter 13's **teaching set**: fifteen 20-second clips of a runner, Quinn, on a
treadmill, three clips a session, before, during and after three weeks of running to a
metronome. The coach's question: did the step rate rise, and did it last?

### Open the table

*Predict first:* What is the typical step rate before the metronome, in steps a minute?

```python
import pandas as pd

df = pd.read_csv("raw/cadence_sessions_synthetic.csv")
print(df.groupby(["day", "phase"])["cadence_spm"].agg(["count", "mean", "std"]).round(1).to_string())
base = df[df["phase"] == "baseline"]["cadence_spm"]
print(f"baseline: mean {base.mean():.1f}, SD {base.std():.2f} steps a minute")
```

Output:

```
                 count   mean  std
day phase                         
1   baseline         3  156.6  1.4
4   baseline         3  157.4  1.1
8   metronome        3  164.9  0.3
22  cue removed      3  162.3  1.0
29  cue removed      3  162.7  1.2
baseline: mean 157.0, SD 1.19 steps a minute
```

### The first chart, and the one-point chart

On the left is what a plotting tool draws by default: every clip in file order, joined by a
line, titled with the column name. On the right is the same data drawn to the fixed template
of Section 13.5.1.

*Predict first:* Which three of the five rules does the default chart break?

```python
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator

m, te = base.mean(), base.std()
day = df.groupby(["day", "phase"], as_index=False)["cadence_spm"].mean()
fig, (a, b) = plt.subplots(1, 2, figsize=(8.0, 2.9))
a.plot(df["cadence_spm"])                                         # the default
a.set_title("cadence_spm")
b.axhspan(m - 2 * te, m + 2 * te, color="0.88", lw=0)              # the athlete's own usual range
b.text(df["day"].max(), m, "your usual range\n(days 1-4)", ha="right", va="center", fontsize=8)
b.plot(df["day"], df["cadence_spm"], ".", color="0.6", ms=5)        # every clip
b.plot(day["day"], day["cadence_spm"], "-o", color="0.1", ms=5)     # each day's mean
mt = day[day["phase"] == "metronome"].iloc[0]
b.annotate("with metronome", (mt["day"], mt["cadence_spm"]), xytext=(8, -12), textcoords="offset points", fontsize=8)
b.set(xlabel="day", ylabel="steps per minute")
b.set_title("Step rate rose about 6 a minute and held without the beat", fontsize=9)
b.yaxis.set_major_locator(MaxNLocator(integer=True))               # no false digits
plt.tight_layout()
print(f"band: {m:.1f} ± {2 * te:.1f} steps a minute")
```

Output:

```
band: 157.0 ± 2.4 steps a minute
```

![Two panels. Left, step rate in file order joined by a line, titled cadence_spm. Right, step rate against day with a gray band for the usual range, gray dots for each clip, black dots joined for each day's mean, the metronome day labeled, and a title saying step rate rose about 6 a minute and held.](https://apopt.com/course/tutorials/q37-one-chart/c03-1.png)

The default chart has no message, no reference, and an x axis in rows rather than days, so
the reader cannot see the metronome or the gap of two weeks. The right-hand chart answers the
coach's question before the reader has read the axes: the last two sessions sit above the
band of Quinn's usual range, and the gray dots show that this is not one lucky clip.

**For the athlete:** "Your step rate on easy runs went from about 157 to about 163 a minute,
and it stayed there after we stopped the beat."

---
Text CC BY 4.0, code MIT. IRSRI Sports Research Institute.
