Skip to main content

SPC Box Plot

Dynamic JSON Badge Grafana

The SPC Box Plot panel visualizes process data distributions as box-and-whisker plots with built-in Statistical Process Control. It automatically groups measurements into subgroups, computes quartiles and outliers, and overlays robust Xf-Rf control limits so you can detect shifts in both process location and spread at a glance.

SPC Box Plot overview

Table of Contents


Why SPC Box Plot?

Control charts and histograms show you one dimension of your process at a time. Box plots show you the entire distribution of each subgroup simultaneously — median, spread, quartiles, and individual outliers — making it easier to spot shifts in both location and variability across time or categories.

When combined with Statistical Process Control:

  • Is my process centering stable? — Xf control limits show whether the typical location of each subgroup stays within expected bounds
  • Is my process spread stable? — Rf out-of-control flags reveal whether within-subgroup variability is in control
  • Where are my outliers? — Individual points beyond the 1.5 × IQR fence are plotted separately so they stand out immediately
  • What is my process capability? — Cp, Cpk, Pp, and Ppk are calculated automatically when LSL/USL control lines are added

SPC Box Plot with control lines

Built for Grafana

SPC Box Plot is built using Grafana's native visualization components. This means it inherits the look, feel, and behavior you already know:

  • Native theming — automatically adapts to light and dark mode
  • Standard panel options — legend placement, tooltip behavior, and field overrides work just like any other Grafana panel
  • Resizable statistics table — drag the splitter to balance chart and table space, just like Grafana's built-in panels
  • Works with any data source — use it with SQL databases, Prometheus, InfluxDB, CSV files, or any other Grafana data source

Features

FeatureDescription
Box-and-whisker plotsQ1, Q3, median, whiskers (1.5 × IQR), and individual outlier points per subgroup
Mean markerOptional marker at the subgroup mean, independent color and size
Outlier plottingData points beyond whisker bounds plotted as individual symbols
Three data modesAuto-detects time series, categorical, or pre-computed input — no configuration needed
Xf-Rf SPCRobust control limits using resistant estimators (Peixoto 1992/2003)
Control linesLCL, UCL, Mean, Min, Max, Range, LSL, USL, Custom, Nominal
Fill regionsColor-fill areas between control lines to highlight process zones
Statistics tablen, Mean, Std Dev, Min, Max, Q1, Median, Q3, IQR, Cp, Cpk, Pp, Ppk, Xf (when SPC enabled)
Resizable layoutDrag the splitter between chart and statistics table
Dashboard variablesControl subgroup size across all panels with a subgroupsize dashboard variable
Interactive tooltipHover to see Q1, Median, Q3, Mean, Min, Max, and control line values

Use Cases

  • Manufacturing quality — compare distributions across shifts, machines, or product variants in the same view
  • Process engineering — detect changes in process spread or centering across sequential time periods
  • Laboratory testing — analyze batch-to-batch variability with full outlier visibility
  • Supply chain — monitor delivery time or fill-rate distributions by supplier, carrier, or route
  • Healthcare — track clinical measurement distributions across patient cohorts or time periods

Requirements

  • Grafana 11.6.2 or later

Getting Started

  1. Install the plugin from the Grafana Plugin Catalog.
  2. Add a new panel to your dashboard and select SPC Box Plot as the visualization type.
  3. Connect a data source that returns numeric time series data.
  4. The panel automatically groups consecutive measurements into subgroups (default size: 5) and displays one box per subgroup.
  5. In the panel editor, go to the SPC section and enable Enable SPC to add Xf-Rf control limits.
  6. Add an LCL and UCL control line to visualize the process control zone.
  7. Add LSL and USL control lines to enable capability index calculations (Cp/Cpk/Pp/Ppk) in the statistics table.

Getting started


Data Modes

The panel automatically detects which input format your data is in. No manual mode selection is needed — the detection order is: pre-computed → categorical → time series.

Time Series Mode

Trigger: Query returns a numeric field with no string field present.

Consecutive measurements are grouped into subgroups of the configured subgroup size. Each complete subgroup becomes one box. Incomplete trailing subgroups (fewer values than the subgroup size) are silently discarded.

Box labels use the timestamp of the first measurement in each subgroup, formatted as YYYY-MM-DD HH:mm. If no time field is present, a 1-based index is used instead.

SPC (Xf-Rf) is only available in this mode.

This is the primary mode for monitoring process stability over time.

Time series mode

Categorical Mode

Trigger: Query returns a string field alongside a numeric field. The panel groups all rows with the same string value into one box.

Each unique category value becomes one box showing the full distribution of all numeric values in that category. Category order follows the order in which unique values are first encountered in the data.

Use this mode to compare distributions across:

  • Products, materials, or part numbers
  • Machine IDs or production lines
  • Operators, shifts, or teams
  • Any other discrete grouping dimension

Categorical mode

Pre-computed Mode

Trigger: Query returns a string field plus numeric fields named min, q1, median, q3, and max (case-insensitive).

The panel renders the pre-computed statistics directly without recalculating anything. This is useful when your database or query already computes box plot statistics (for example, using SQL percentile_cont functions or a time series aggregation pipeline).

Required fields:

FieldRequiredDescription
String fieldYesCategory label for each row
minYesWhisker minimum
q1YesFirst quartile
medianYesMedian
q3YesThird quartile
maxYesWhisker maximum
meanNoMean (estimated as (Q1+Q3)/2 if absent)
countNoSample size shown in the statistics table
note

When using pre-computed mode, the statistics table will show approximate values for standard deviation (estimated from IQR as IQR / 1.35, assuming a normal distribution). SPC is not available in this mode.


Panel Options

All SPC Box Plot options are grouped in the panel editor sidebar.

Box Appearance

OptionDescriptionDefault
Box colorFill and border color of the box bodyBlue
Fill opacityTransparency of the box fill (0–100%)50%
Line widthBox border thickness in pixels (1–10)1
Box widthFraction of available space each box occupies (0.1–1.0)0.6
Median colorColor of the median line inside the boxOrange
Median line widthThickness of the median line in pixels (1–10)2

Categorical mode

Whiskers

OptionDescriptionDefault
Whisker styleSolid or Dashed line styleSolid
Whisker line widthThickness of the whisker lines in pixels (1–10)1

Whiskers extend from Q1 downward and from Q3 upward to the farthest data point that is still within 1.5 × IQR of the respective quartile:

  • Lower whisker: farthest value ≥ Q1 − 1.5 × IQR
  • Upper whisker: farthest value ≤ Q3 + 1.5 × IQR

Any values outside these bounds are plotted as individual outlier points (if outlier display is enabled).

Mean Marker

OptionDescriptionDefault
Show meanDisplay a marker at the subgroup meanOn
Mean colorColor of the mean markerRed
Mean sizeDiameter of the mean marker in pixels5
Mean line widthBorder thickness of the mean marker in pixels2

The mean marker appears as a diamond symbol overlaid on the box, allowing you to see at a glance whether the mean and median are aligned (symmetric distribution) or diverge (skewed distribution).

Outliers

OptionDescriptionDefault
Show outliersPlot individual data points beyond the whisker boundsOn
Outlier colorColor of the outlier pointsRed
Outlier sizeDiameter of the outlier points in pixels4

Outlier points are plotted individually as circles. When multiple outliers have the same value they overlap, so very high-count distributions may show a column of stacked dots at the same position.

SPC (Xf-Rf)

SPC options are only available when the panel is in time series mode. The section is hidden for categorical and pre-computed data.

OptionDescriptionDefault
Enable SPCCalculate and display Xf-Rf control limitsOn
Subgroup sizeNumber of consecutive measurements per subgroup (4–15)5

When SPC is enabled:

  • The LCL and UCL calculated control lines become available to add to the chart.
  • Boxes whose Rf (range of the middle half) exceeds D4F×RfˉD_{4F} \times \bar{R_f} are flagged as out of control.
  • The per-subgroup Xf column (mean of the middle half) appears in the statistics table.
  • The sigma estimate σ^=Rfˉ/d4\hat{\sigma} = \bar{R_f} / d_4 is used instead of the sample standard deviation for Cp and Cpk calculations.

See Xf-Rf Control Chart for the full mathematical description.

Statistics Table

OptionDescriptionDefault
Show statistics tableDisplay the resizable statistics table below the chartOn
Visible columnsSelect which columns appear in the tableAll

The statistics table shows one row per box (subgroup or category). It is sortable by clicking any column header. Drag the splitter between the chart and the table to adjust the vertical split.

Available columns:

ColumnDescription
nSample count (number of values in the subgroup)
MeanArithmetic mean
Std DevSample standard deviation (Bessel's correction, n−1 denominator)
MinMinimum value (lower whisker bound)
MaxMaximum value (upper whisker bound)
Q1First quartile (25th percentile, linear interpolation)
MedianMedian (50th percentile)
Q3Third quartile (75th percentile)
IQRInterquartile range (Q3 − Q1)
CpShort-term potential capability index (requires LSL and USL control lines)
CpkShort-term centered capability index (requires LSL or USL)
PpLong-term performance capability index (requires LSL and USL)
PpkLong-term centered performance capability index (requires LSL or USL)
XfPer-subgroup mean of the middle half (only shown when SPC is enabled)

Statistics table

Legend

Standard Grafana legend options are available:

  • Display mode: List, Table, or Hidden
  • Placement: Bottom or Right
  • Values: Min, Max, Mean, and other standard reducers

The legend shows entries for each visible control line and for the box plot series name.


Control Lines

A control line is a horizontal reference line drawn across the entire chart at a specified Y-axis position. Lines can be calculated automatically from the data, manually specified as a fixed value, or pulled dynamically from a field in a data query.

Control lines with fill regions

Calculated Control Lines

Calculated lines are derived from the data. They update automatically when the data changes.

LineDescriptionAvailabilityDefault color
LCLLower Control Limit (Xf-Rf)Only when SPC is enabledRed
UCLUpper Control Limit (Xf-Rf)Only when SPC is enabledRed
MeanGrand mean of all valuesAlwaysDark Blue
MinGlobal minimum valueAlwaysBlue
MaxGlobal maximum valueAlwaysBlue
RangeGlobal max minus global minAlwaysPurple

Each calculated line type can only be added once per panel. When you enable SPC, LCL, UCL, and Mean are not added automatically — you add them explicitly from the control line editor.

Custom Control Lines

Custom lines are set to a fixed value or read from a data series. Multiple lines of the same type can be added.

Line TypeDescriptionDefault color
CustomA general-purpose reference lineDark Green
NominalThe target or nominal process valueDark Green
LSLLower Specification Limit — enables Cp/Cpk/Pp/Ppk calculationDark Red
USLUpper Specification Limit — enables Cp/Cpk/Pp/Ppk calculationDark Red

Control Line Appearance

Each control line has the following configurable properties:

PropertyDescription
NameDisplay name shown in the legend and tooltip
PositionY-axis value where the line is drawn (Static mode)
Line widthLine thickness in pixels (1–10)
ColorLine color — uses Grafana's color picker
Fill directionBelow (−1), None (0), or Above (+1)
Fill opacityOpacity of the filled region (0–100%)

Fill Regions

Setting Fill direction to Above or Below creates a shaded region extending from the line outward. The fill is clipped at the nearest adjacent control line, so placing fill on both LCL (Above) and UCL (Below) creates a shaded band between the two lines.

Common pattern — highlight the in-control zone:

  1. Add an LCL line, set Fill Direction to Above with a low opacity (e.g., 10%).
  2. Add a UCL line, set Fill Direction to Below with the same opacity.

The two fills overlap between the lines, producing a visible band marking the acceptable process range.


Xf-Rf Control Chart

The SPC Box Plot implements the Xf-Rf resistant control chart described in:

Peixoto, J. L. (1992). A property of well-formulated polynomial regression models. The American Statistician. Later applied to resistant estimators for Shewhart-type box plot control charts (2003), distributed as technical report COB03-1499.

This chart type is specifically designed for subgroup data where individual observations within each subgroup may contain outliers.

Why Resistant Estimators?

Traditional Xbar-R charts estimate process location with the subgroup mean (Xˉ\bar{X}) and process spread with the subgroup range (R). Both statistics are sensitive to extreme values — a single outlier in a subgroup inflates both the mean and the range, producing control limits that are too wide and may mask genuine process signals.

The Xf-Rf chart replaces these with resistant estimators based on the middle half of each sorted subgroup:

  • Xf (mean of the middle half) estimates the subgroup center without being pulled by the most extreme values
  • Rf (range of the middle half) estimates the subgroup spread using only the central portion of the data

By discarding the outermost quarter of values on each side before computing each statistic, both estimators become robust. A small number of extreme observations within a subgroup cannot meaningfully bias the resulting control limits. This makes the Xf-Rf chart particularly well suited to box plot panels, where you want to distinguish between within-subgroup outliers (visible as individual dots on the box plot) and between-subgroup shifts in location or spread (visible as Xf control limit violations).

Middle-Half Index f

For a subgroup of size n, the boundary index f is computed as:

f=(n+3)/2/2f = \lfloor (n + 3) / 2 \rfloor / 2

This determines which order statistics bound the "middle half". For example:

  • n = 5: f = ⌊8/2⌋/2 = 4/2 = 2.0 (integer) → use order statistics X_(2) through X_(4)
  • n = 4: f = ⌊7/2⌋/2 = 3/2 = 1.5 (half-integer) → use fractional order statistics at positions 1.5 and 3.5

Xf — Mean of Middle Half

Case 1: f is an integer

Xf = mean of X_(f), X_(f+1), ..., X_(n+1−f) (using 1-based order statistics)

Xf=j=fn+1fX(j)n+22fX_f = \frac{\sum_{j=f}^{n+1-f} X_{(j)}}{n + 2 - 2f}

Case 2: f is a half-integer (f = i + ½)

Fractional order statistics are linearly interpolated: X(i+12)=0.5×(X(i)+X(i+1))X_{(i+\frac{1}{2})} = 0.5 \times (X_{(i)} + X_{(i+1)})

Xf=X(f)+X(n+1f)+j=i+2ni1X(j)n2iX_f = \frac{X_{(f)} + X_{(n+1-f)} + \sum_{j=i+2}^{n-i-1} X_{(j)}}{n - 2i}

Rf — Range of Middle Half

Rf=X(n+1f)X(f)R_f = X_{(n+1-f)} - X_{(f)}

For half-integer f, the boundary order statistics are interpolated from adjacent pairs as described above.

Control Limits

After computing Xf and Rf for every subgroup, the chart averages across all k subgroups:

Xfˉ=1kXfi\bar{X_f} = \frac{1}{k} \sum X_{f_i}

Rfˉ=1kRfi\bar{R_f} = \frac{1}{k} \sum R_{f_i}

The control limits for the Xf chart (monitoring subgroup location) are:

LineFormula
Center Line (CL)Xfˉ\bar{X_f}
UCLXfˉ+A2F×Rfˉ\bar{X_f} + A_{2F} \times \bar{R_f}
LCLXfˉA2F×Rfˉ\bar{X_f} - A_{2F} \times \bar{R_f}

The control limits for the Rf chart (monitoring subgroup spread — used for flagging only, not displayed as separate lines):

LineFormula
Center LineRfˉ\bar{R_f}
UCL (Rf)D4F×RfˉD_{4F} \times \bar{R_f}
LCL (Rf)D3F×RfˉD_{3F} \times \bar{R_f}

Sigma Estimate

The within-subgroup process standard deviation is estimated as:

σ^=Rfˉ/d4\hat{\sigma} = \bar{R_f} / d_4

This resistant sigma estimate is used in the Cp and Cpk capability index calculations when SPC is enabled.

Out-of-Control Detection

A subgroup is flagged as out of control when its Rf value falls outside the Rf control limits:

Rfi>D4F×RfˉorRfi<D3F×Rfˉ(D3F>0)R_{f_i} > D_{4F} \times \bar{R_f} \quad \text{or} \quad R_{f_i} < D_{3F} \times \bar{R_f} \quad (D_{3F} > 0)

Flagged boxes are visually highlighted on the chart.

note

The current implementation flags based on spread (Rf) out-of-control only. Location (Xf) violations are visible from the UCL/LCL control lines but are not separately flagged with a visual marker.

Xf-Rf Constants Table

The constants A2F, D3F, D4F, and d4 are taken from Table 2 of Peixoto (2003). The implementation is valid for subgroup sizes n = 4 to 15. Subgroup sizes outside this range are not supported (SPC will not activate).

nA2FD3FD4Fd4
41.1310.0002.3251.326
51.4440.0002.7230.990
61.0030.0002.3781.283
71.0740.0002.2261.110
80.8400.0002.0721.325
90.9390.0002.2251.143
100.7700.0002.0821.312
110.8160.0002.0051.190
120.6960.0841.9161.329
130.7740.0002.0031.205
140.6490.0801.9201.323
150.6810.1281.8721.230

Notation:

  • A2F — multiplier for Xf control limits: UCL/LCL = Xfˉ±A2F×Rfˉ\bar{X_f} \pm A_{2F} \times \bar{R_f}
  • D3F — lower multiplier for Rf control limits: LCL(Rf) = D3F×RfˉD_{3F} \times \bar{R_f}
  • D4F — upper multiplier for Rf control limits: UCL(Rf) = D4F×RfˉD_{4F} \times \bar{R_f}
  • d4 — divisor for sigma estimate: σ^=Rfˉ/d4\hat{\sigma} = \bar{R_f} / d_4

Capability Indices

When LSL (Lower Specification Limit) and/or USL (Upper Specification Limit) control lines are configured, the statistics table automatically calculates process capability indices for each subgroup row.

IndexFormulaDescription
Cp(USLLSL)/(6σ^)(USL - LSL) / (6\hat{\sigma})Short-term potential capability. Measures whether the process spread fits within the specification window, ignoring centering. Requires both LSL and USL.
Cpkmin((USLμ)/3σ^, (μLSL)/3σ^)\min((USL - \mu) / 3\hat{\sigma},\ (\mu - LSL) / 3\hat{\sigma})Short-term centered capability. Accounts for how well the process is centered relative to the specification limits. Requires at least one of LSL or USL.
Pp(USLLSL)/(6s)(USL - LSL) / (6s)Long-term performance capability. Uses the sample standard deviation s instead of σ^\hat{\sigma}. Represents actual observed performance over the full data range. Requires both LSL and USL.
Ppkmin((USLμ)/3s, (μLSL)/3s)\min((USL - \mu) / 3s,\ (\mu - LSL) / 3s)Long-term centered performance capability. Accounts for centering using long-term variability.

Notation:

  • μ = subgroup mean
  • σ^\hat{\sigma} = resistant sigma estimate from Xf-Rf (Rfˉ/d4\bar{R_f} / d_4); falls back to sample StdDev if SPC is disabled
  • s = sample standard deviation (n−1 denominator)

Interpretation guidance:

ValueInterpretation
Cp/Cpk < 1.00Process is not capable — producing output outside specification
1.00 ≤ Cp/Cpk < 1.33Marginally capable — acceptable only for non-critical characteristics
1.33 ≤ Cp/Cpk < 1.67Capable — meets most industry requirements
Cp/Cpk ≥ 1.67Highly capable

Note that Cpk ≤ Cp always. A large difference between Cp and Cpk indicates the process is capable but poorly centered.


Dashboard Variables

The panel supports a dashboard variable named subgroupsize (case-insensitive — subgroupsize, subgroupSize, and SUBGROUPSIZE all work). When this variable exists on the dashboard, it overrides the subgroup size setting in every SPC Box Plot panel, allowing you to adjust subgrouping for an entire dashboard from a single dropdown.

To configure the variable:

  1. Go to Dashboard Settings > Variables.
  2. Click Add variable.
  3. Set Name to subgroupsize.
  4. Set Type to Custom.
  5. In the Custom options field, enter a comma-separated list of valid sizes, for example: 4,5,6,7,8,10.
  6. Save the dashboard.

All SPC Box Plot panels will immediately reflect the selected variable value. When the variable is active, the subgroup size field in the panel editor is disabled and shows the variable's current value.

caution

Subgroup sizes must be between 4 and 15 for SPC to activate. Values outside this range are accepted by the variable but will disable SPC calculations.


Part of the KensoBI SPC Suite

SPC Box Plot is part of a growing family of Statistical Process Control plugins for Grafana by Kenso Software:

SPC Chart Panel — Control charts for monitoring process stability over time. Supports XmR, Xbar-R, and Xbar-S charts with automatic calculation of control limits. If you're tracking whether a process is staying in control, start here.

SPC Histogram Panel — Distribution analysis with histograms, bell curves, and a built-in statistics table showing Cp, Cpk, Pp, and Ppk. Use it to understand process capability: is your process producing results within specification limits?

SPC Pareto Panel — Pareto charts for identifying the most significant factors contributing to defects or issues. Automatic sorting, cumulative percentage lines, and 80/20 threshold analysis help you focus improvement efforts where they matter most.

SPC CAD Panel — Brings 3D geometry into the picture, letting you bind the data from control charts and histograms to physical features on your parts.

Getting Help