Sub topic 6
Looking before testing: graphs that support or challenge the cause
This chapter assumes you know the basics of DMAIC, can read a histogram and a run chart, and can compute a mean, median and standard deviation. It also assumes you have a suspected root cause written as a testable hypothesis, with a data collection plan and data you have already checked for quality. The next step is to plot the data before you run any test.
Why plot first
A hypothesis test returns one number, and that number hides the shape of the data. Graphs show what the test cannot:
- Outliers and data entry errors.
- Drift over time.
- Two clusters mixed into one column.
- A difference that exists in only one part of the process.
- A relationship that is curved rather than straight.
Every test also rests on assumptions: independent observations, similar spread, and no extreme points. Graphs are the cheapest way to check them.
Graphs also fit the logic of verification. You wrote a prediction such as "if the suspect setup is the cause, cycle time will be higher under that setup." A graph lets you see whether the data move in that direction. If they do not, you can reject or revise the cause before spending effort on formal testing.
Graphs only suggest. A visible difference can come from chance, and an invisible one can hide in a small sample. The test in the next chapter puts a number on that risk.
Choosing the graph from the question
Pick the graph by the question you are asking, not by habit.
| Graph | Question it answers | Data needed | Typical warning sign |
|---|---|---|---|
| Run chart | Did the output shift, trend or cycle when the suspected cause changed? | Y in time order | Step change that lines up with a change in X |
| Boxplot | Does Y differ between levels of a factor? | Continuous Y plus a group label | Medians far apart, little overlap |
| Scatter plot | Does Y move with a continuous X? | Paired X and Y | Slope, curve, or clusters |
| Pareto chart | Which categories account for most defects? | Counts per category | One or two bars dominate |
Run chart: does the signal line up with the cause?
A run chart plots Y in the order the data were produced. It is the best check on a time-linked suspicion, such as "the problem started when we changed supplier" or "it gets worse after lunch."
Mark the point where the suspected cause changed. If Y shifts at that point and stays shifted, the cause stays plausible. If Y was already high before the change, the cause cannot explain the problem.
import numpy as np
import matplotlib.pyplot as plt
rng = np.random.default_rng(7)
# 30 units on the old setup, then 30 on the suspect setup
old = rng.normal(12.2, 0.3, 30)
suspect = rng.normal(13.0, 0.3, 30)
y = np.concatenate([old, suspect])
order = np.arange(1, len(y) + 1)
fig, ax = plt.subplots(figsize=(8, 3.5))
ax.plot(order, y, marker="o", markersize=3, linewidth=1)
ax.axhline(np.median(y), linestyle="--", color="gray", label="overall median")
ax.axvline(30.5, color="red", label="setup changed")
ax.set_xlabel("Production order")
ax.set_ylabel("Cycle time (min)")
ax.set_title("Run chart of cycle time")
ax.legend()
plt.tight_layout()
plt.savefig("run_chart.png", dpi=120)Read it for these patterns:
- A step at the marked line. This supports the cause, though anything else that changed at that moment would produce the same step.
- A run of 7 or more points on one side of the median. This is a common rule of thumb for a non-random shift.
- A steady trend. Tool wear or warm-up may be the real driver, not the suspected cause.
- Sawtooth or repeating cycles. These point to a periodic factor such as shift change or a daily temperature swing.
Boxplot: comparing groups
A boxplot summarizes each group with its median, the interquartile range (the box, covering the middle 50% of points), and whiskers that usually reach 1.5 times that range. Points beyond the whiskers are drawn individually as potential outliers.
Use side-by-side boxplots when your hypothesis names a categorical factor, such as setup, shift, machine or supplier.
import numpy as np
import matplotlib.pyplot as plt
setup_old = np.array([12.1, 11.8, 12.4, 12.0, 12.6, 11.9, 12.3, 12.2])
setup_suspect = np.array([13.0, 12.8, 13.4, 12.9, 13.1, 13.5, 12.7, 13.2])
fig, ax = plt.subplots(figsize=(5, 4))
ax.boxplot([setup_old, setup_suspect])
ax.set_xticks([1, 2])
ax.set_xticklabels(["Old setup", "Suspect setup"])
ax.set_ylabel("Cycle time (min)")
ax.set_title("Cycle time by setup")
plt.tight_layout()
plt.savefig("boxplot.png", dpi=120)What to look for:
- Separation of medians relative to the box height. If one median lies outside the other group's box, the difference is probably real.
- Spread. A suspect group with a much wider box suggests the factor changes variation, not just the mean. This matters for choosing the test.
- Skew. A median pushed to one side of the box, or a long whisker, warns you that a mean-based test may mislead.
- Sample size. A boxplot of 5 points looks as tidy as one of 500. Print the group counts next to the graph, or overlay the raw points.
Overlap does not mean there is no effect. Two boxes can overlap and still have means that differ reliably when samples are large.
Scatter plot: a continuous suspect
When both the suspected cause X and the output Y are numeric, such as oven temperature and defect rate, plot X on the horizontal axis and Y on the vertical axis. Coloring the points by a third variable, such as shift, quickly shows whether a pattern holds within each group or comes from mixing groups.
import numpy as np
import matplotlib.pyplot as plt
rng = np.random.default_rng(3)
n = 60
temp = rng.uniform(170, 200, n)
shift = rng.choice(["A", "B"], n)
# Defect rate rises with temperature; shift B is a little higher overall
rate = 0.02 * (temp - 170) + (shift == "B") * 0.3 + rng.normal(0, 0.2, n)
fig, ax = plt.subplots(figsize=(6, 4))
for s, color in [("A", "tab:blue"), ("B", "tab:orange")]:
mask = shift == s
ax.scatter(temp[mask], rate[mask], label=f"Shift {s}", color=color, s=20)
ax.set_xlabel("Oven temperature (°C)")
ax.set_ylabel("Defect rate (%)")
ax.set_title("Defect rate versus oven temperature")
ax.legend()
plt.tight_layout()
plt.savefig("scatter.png", dpi=120)Look at the shape before you compute anything:
- A clear slope supports a relationship. You will quantify it with correlation and regression later.
- A curve or a plateau means a straight-line summary will mislead.
- Separate clouds mean a hidden factor, as the shift colors show here.
- A few extreme points can create or destroy an apparent trend.
- A flat cloud challenges the cause, as long as the X values covered a wide enough range. If operators only ever ran the oven between 180 and 182 °C, the plot cannot tell you what happens at 200 °C.
Pareto chart: is this cause where the defects are?
A Pareto chart sorts categories from largest to smallest count and adds a cumulative percentage line. Use it to check that the suspected cause addresses a meaningful share of the problem. If you have verified a cause that explains 4% of the defects, the project will not meet its goal.
import pandas as pd
import matplotlib.pyplot as plt
defects = pd.Series(
{"Scratch": 48, "Misalignment": 31, "Dent": 12, "Discoloration": 6, "Other": 3}
).sort_values(ascending=False)
cum_pct = defects.cumsum() / defects.sum() * 100
fig, ax = plt.subplots(figsize=(7, 4))
ax.bar(defects.index, defects.values, color="tab:blue")
ax.set_ylabel("Defect count")
ax.tick_params(axis="x", rotation=30)
ax2 = ax.twinx()
ax2.plot(defects.index, cum_pct.values, color="tab:red", marker="o")
ax2.set_ylim(0, 105)
ax2.set_ylabel("Cumulative %")
ax.set_title("Pareto chart of defect types")
plt.tight_layout()
plt.savefig("pareto.png", dpi=120)Run the Pareto on the same data stratified by your suspected factor. If misalignments concentrate on one machine, the suspicion about that machine gains support. If they spread evenly across machines, it loses support.
Common errors
- Choosing the axis range to flatter the story. A truncated y-axis makes a 0.2-minute difference look dramatic. Use the same scale across the graphs you compare, and state the units.
- Reading a boxplot as a time series. A boxplot hides order. Always pair it with a run chart when drift is possible.
- Plotting aggregated data. Averages per day hide the unit-level spread. Plot individual values when you have them.
- Ignoring group size. A boxplot of 4 points per group should not be trusted as much as one of 100.
- Seeing what you expect. After you form a hypothesis, you tend to read ambiguous graphs in its favor. Write down beforehand what pattern would count against the cause, then check for it.
- Treating the graph as the verdict. A graph can raise or lower your confidence, but it cannot give you an error rate. That job belongs to the test.
A short checklist before moving on
- Plot Y in time order and mark the moment the suspected X changed.
- Compare groups with boxplots, and show the group sizes.
- For a numeric X, make a scatter plot, color it by any likely confounding factor, and check the X range.
- Run a Pareto to confirm the cause covers a worthwhile share of the defects.
- Write down what you saw: whether it supports, contradicts, or is unclear about the cause, and which assumptions of the planned test the graphs raised concerns about.
Exercise
A run chart of weekly defect counts shows the rate rising steadily for 12 weeks before a new supplier's material was introduced, then continuing to rise at the same slope afterward. Does this graph support the claim that the new supplier caused the increase? Name one other graph you would make next.
Show answer
No. The upward trend began before the supplier change and did not change slope at that point, so the supplier change does not explain it. Something else is driving the trend, such as tool wear, seasonal conditions or a gradual process change. A useful next graph is a Pareto chart or boxplot stratified by machine, shift or operator, to find where the increase is concentrated. A scatter plot of defect rate against a candidate continuous factor, such as temperature, would also help.
Exercise
Two boxplots of cycle time, one per machine, show similar medians, but machine 2 has a box that is three times taller than machine 1. What does this suggest about the suspected cause "machine 2 makes cycle time worse," and how might it affect your choice of test?
Show answer
The cause may still be real, but it affects variation rather than the average. Machine 2 is less consistent, which can produce more late units even with the same median. A test of means may find no difference, so you should also compare the spread, for example with a variance test, and avoid assuming equal variances. A Welch t-test is safer than a pooled t-test here.