Multi-Factor / DOE Plots

Multi-factor EDA analyses designed experiments (DOE) where multiple factors are varied simultaneously. Pass named factor arrays via the factors dict to EDAData.

The plots answer: which factors drive location or spread, and what does the response surface look like?

Reference: NIST Handbook Chapter 5

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from drippy import EDAData
from drippy import (
    doe_scatter_plot,
    doe_mean_plot,
    doe_sd_plot,
    contour_plot,
)

rng = np.random.default_rng(42)

# 2-factor full-factorial DOE — 16 runs
# Factor A: temperature (+1 = high, −1 = low)
# Factor B: pressure (+1 = high, −1 = low)
# Response: process yield
A = np.tile([-1, 1], 8)
B = np.repeat([-1, 1], 8)
y = 2.0 * A + 1.5 * B + 0.5 * A * B + rng.normal(scale=0.3, size=16)
data = EDAData(y=y, factors={"Temperature": A, "Pressure": B})

DOE Scatter Plot

One subplot per factor. Scatters y against each factor’s coded level to reveal the raw relationship before any modelling.

fig, axes = doe_scatter_plot(data)
plt.show()
../_images/395d8063edd7b9a0c350e0a2c0a82c31c50afd307470c4dccb847786addc0852.png

DOE Mean Plot

For each factor, plots the mean response at each level and draws the grand mean as a reference. Steep slopes signal large main effects.

fig, axes = doe_mean_plot(data)
plt.show()
../_images/136dfced5288fc336fc75b333365f7344bdf76c07d33118d3a7ed8364a197aee.png

Temperature has a larger slope than Pressure, indicating a stronger effect on yield.

DOE SD Plot

Like the mean plot but for within-level standard deviations. Detects factors that affect process variability, not just location.

fig, axes = doe_sd_plot(data)
plt.show()
../_images/7261c75f546d3f36696e7c7fa083877baac3b156786495b4d204137d03f840cc.png

Contour Plot (NIST 1.3.3.10)

Interpolates a contour surface over the 2-factor design space. Requires exactly two factors. Optimal conditions appear as peaks or ridges in the surface.

fig, ax = contour_plot(data)
plt.show()
../_images/a72ec9f478d22faafaf5c0cdb56c1d345b61672be4f76257609bba769191bbdc.png

Overlay the actual design points:

fig, ax = contour_plot(data, doe=True)
plt.show()
../_images/c58aa1a0fabe90c7dcf7317e313e29fa6a8ee9a79172111a1cfe44a23c59333e.png