svggage-components
Gauge R&R components
How much of the observed variation comes from the measurement system rather than the parts?
How to read it
- Read each cluster as one variance source, by three measures.
- Compare gauge R&R with the 10% and 30% guidelines.
- Part-to-part should dominate if the gauge is good.
- Callout 1: Gauge R&R: the measurement system.
- Callout 2: Part-to-part: what you want to see.
- Callout 3: Guidelines: below 10% is good, above 30% is not.
Watch out
- Too few parts or operators make these percentages very uncertain.
Defaults
No settings: the chart draws one way.
Pinned in the code
- Draws the run's numbers as given (computed by the Python/R engine); the chart computes nothing statistical.
- Values are percentages (fractions ≤ 1.5 are scaled to percent). % contribution is on the variance scale and sums to 100; % study variation is on the SD scale (6σ) and does not.
- AIAG guidelines on % study variation: under 10% acceptable, 10–30% may be acceptable, over 30% unacceptable; the engine also reports the number of distinct categories.
# Gauge R&R components — Codesplash Chart Lab (recipe "gage-components")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import to_rgba
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]
# non-colour encodings per series (same table as the app: series are never told apart by colour alone)
SERIES_HATCHES = ["", "////", "..", "\\\\\\\\", "---", "xx", "|||", "++"]
HATCH_INK = to_rgba(plt.rcParams["axes.facecolor"], 0.5) # stripes let the chart surface show through
df = pd.read_csv("gage-components-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["source"] = pd.Categorical(df["source"].astype("string"), categories=["Gauge R&R", "Repeatability", "Reproducibility", "Part-to-part"])
df["measure"] = pd.Categorical(df["measure"].astype("string"), categories=["contribution", "study_var", "tolerance"])
def levels_of(s):
"""Declared level order (categoricals), else order of first appearance."""
if isinstance(s.dtype, pd.CategoricalDtype):
return [v for v in s.cat.categories if (s == v).any()]
return list(dict.fromkeys(s.dropna().astype(str)))
S = "source"
V = "percent"
ME = "measure"
d = df.dropna(subset=[S, V]).copy()
d["_m"] = d[ME].astype(str) if ME else "contribution"
scale = 100 if d[V].max() <= 1.5 else 1 # fractions → percent
sources, measures = levels_of(d[S]), levels_of(d["_m"])
w = 0.8 / len(measures)
fig, ax = plt.subplots(figsize=(8, 4.5))
for j, m in enumerate(measures):
vals = [d.loc[(d[S].astype(str) == str(s)) & (d["_m"] == m), V].sum() * scale for s in sources]
ax.bar(np.arange(len(sources)) + (j - (len(measures) - 1) / 2) * w, vals, width=w * 0.95, color=PALETTE[j % len(PALETTE)], label=m, hatch=SERIES_HATCHES[j % 8], hatchcolor=HATCH_INK, linewidth=0) # texture per measure, as in the app
for t in (10, 30): # AIAG guidelines
ax.axhline(t, color="grey", linestyle="--", linewidth=1)
ax.set_xticks(range(len(sources)), [str(s) for s in sources])
ax.set_ylabel("percent")
ax.legend(fontsize=8)
plt.show()Needs pandas, numpy, matplotlib · reads gage-components-demo.csv · app theme from the optional codesplash helper
# Gauge R&R components — Codesplash Chart Lab (recipe "gage-components")
# controls: defaults
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else px.colors.qualitative.Plotly
# non-colour encodings per series (same table as the app: series are never told apart by colour alone)
SERIES_HATCHES = ["", "/", ".", "\\", "-", "x", "|", "+"]
HATCH_INK = "rgba(255,255,255,0.5)" # stripes let the chart surface show through
df = pd.read_csv("gage-components-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["source"] = pd.Categorical(df["source"].astype("string"), categories=["Gauge R&R", "Repeatability", "Reproducibility", "Part-to-part"])
df["measure"] = pd.Categorical(df["measure"].astype("string"), categories=["contribution", "study_var", "tolerance"])
def levels_of(s):
"""Declared level order (categoricals), else order of first appearance."""
if isinstance(s.dtype, pd.CategoricalDtype):
return [v for v in s.cat.categories if (s == v).any()]
return list(dict.fromkeys(s.dropna().astype(str)))
S = "source"
V = "percent"
ME = "measure"
d = df.dropna(subset=[S, V]).copy()
d["_m"] = d[ME].astype(str) if ME else "contribution"
d["pct"] = d[V] * (100 if d[V].max() <= 1.5 else 1)
fig = px.bar(d, x=S, y="pct", color="_m", barmode="group", color_discrete_sequence=PALETTE, category_orders={S: levels_of(d[S])},
pattern_shape="_m", pattern_shape_sequence=SERIES_HATCHES) # texture per measure, as in the app
fig.update_traces(marker_pattern_fgcolor=HATCH_INK, marker_pattern_fillmode="overlay")
for t in (10, 30):
fig.add_hline(y=t, line=dict(color="grey", dash="dash", width=1))
fig.update_layout(yaxis_title="percent", legend_title=None)
fig.show()Needs pandas, numpy, plotly · reads gage-components-demo.csv · app theme from the optional codesplash helper
# Gauge R&R components — Codesplash Chart Lab (recipe "gage-components")
# controls: defaults
library(ggplot2)
has_cs <- isTRUE(requireNamespace("codesplashr", quietly = TRUE)) # optional: the app's chart theme
theme_cs <- if (has_cs) codesplashr::theme_codesplash(dark = FALSE) else theme_minimal()
cs_cat <- if (has_cs) codesplashr::cs_palette(dark = FALSE)$categorical else grDevices::palette.colors(8, "Okabe-Ito")
if (has_cs) update_geom_defaults("text", list(colour = codesplashr::cs_palette(dark = FALSE)$foreground))
# non-colour encodings per series (same table as the app: series are never told apart by colour alone)
cs_textures <- function(cols, idx = seq_along(cols), bg = "#ffffff") {
# solid, hatch, dots, back-hatch, rows, cross, columns, grid: stripes and dots in the surface colour at 50 %, over the series colour
ink <- grDevices::adjustcolor(bg, alpha.f = 0.5)
seg <- function(x0, y0, x1, y1) grid::segmentsGrob(x0, y0, x1, y1, gp = grid::gpar(col = ink, lwd = 1.2))
marks <- list(NULL, seg(0, 0, 1, 1), grid::circleGrob(0.5, 0.5, r = 0.22, gp = grid::gpar(fill = ink, col = NA)), seg(0, 1, 1, 0),
seg(0, 0.5, 1, 0.5), grid::gList(seg(0, 0, 1, 1), seg(0, 1, 1, 0)), seg(0.5, 0, 0.5, 1), grid::gList(seg(0, 0.5, 1, 0.5), seg(0.5, 0, 0.5, 1)))
lapply(seq_along(cols), function(i) {
m <- marks[[(idx[[i]] - 1) %% 8 + 1]]
if (is.null(m)) return(cols[[i]])
size <- grid::unit(2.4, "mm") # the tile gets its own viewport, so npc units above are tile-relative
tile <- grid::gTree(children = grid::gList(grid::rectGrob(gp = grid::gpar(fill = cols[[i]], col = NA)), m), vp = grid::viewport(width = size, height = size))
grid::pattern(tile, width = size, height = size, extend = "repeat")
})
}
df <- read.csv("gage-components-demo.csv", check.names = FALSE, stringsAsFactors = FALSE, na.strings = "") # empty cells are missing; Chart Lab → Code → Download demo CSV
df[["source"]] <- factor(df[["source"]], levels = c("Gauge R&R", "Repeatability", "Reproducibility", "Part-to-part"))
df[["measure"]] <- factor(df[["measure"]], levels = c("contribution", "study_var", "tolerance"))
levels_of <- function(v) if (is.factor(v)) levels(droplevels(v)) else unique(as.character(v[!is.na(v)]))
s_col <- "source"
v_col <- "percent"
m_col <- "measure"
d <- data.frame(s = factor(as.character(df[[s_col]]), levels = levels_of(df[[s_col]])), v = df[[v_col]],
m = if (is.null(m_col)) "contribution" else as.character(df[[m_col]]))
if (max(d$v, na.rm = TRUE) <= 1.5) d$v <- d$v * 100 # fractions → percent
d$m <- factor(d$m, levels = unique(d$m))
p <- ggplot(d, aes(s, v, fill = m)) + geom_col(position = position_dodge(0.85), width = 0.8) +
geom_hline(yintercept = c(10, 30), colour = "grey50", linetype = "dashed") +
scale_fill_manual(values = cs_textures(cs_cat)) + labs(x = NULL, y = "percent", fill = NULL) + theme_cs # texture per measure, as in the app
print(p)Needs ggplot2 · reads gage-components-demo.csv · app theme from the optional codesplashr helper