How to make a histogram
- Enter the data. Paste a column from Excel or Google Sheets, type the values, or upload a .csv / .xlsx file. A header row becomes the axis title. If the file has several columns, pick the one to plot.
- Choose the bins. Leave the automatic rule, pick another rule, or set the number of bins, the bin width and the start of the first bin yourself.
- Add the specification. Enter LSL, USL and target to draw them as vertical lines. Bins that lie completely outside the limits are coloured red and the observed percentage outside specification is reported.
- Finish and export. Set the titles, switch between frequency, relative frequency and density, then download PNG or SVG, download the frequency table as CSV, or print the page.
How many bins? The rules explained
A histogram groups the data into intervals of equal width and draws a bar for the count in each. Too few bins hide the shape; too many turn it into noise. The automatic rules estimate a sensible number from the sample size n and the spread:
| Rule | Formula | When to use it |
|---|---|---|
| Sturges | k = ⌈log₂ n⌉ + 1 bins | Default. Good for roughly symmetric data up to a few hundred values. |
| Scott | width = 3.49 · s · n−1/3 | Near-normal data; uses the standard deviation s, so it adapts to the spread. |
| Freedman–Diaconis | width = 2 · IQR · n−1/3 | Skewed data or data with outliers; the interquartile range is not inflated by extreme values. |
| Square root | k = ⌈√n⌉ bins | The quick shop-floor rule used by spreadsheet programs. |
| Manual | your k, width and start | To match a customer format or the gauge resolution. |
With “Round to nice bin edges” switched on, the width is rounded to the nearest 1, 2, 2.5 or 5 × 10ᵏ and the first bin starts on a multiple of that width, so the axis labels are easy to read. If that width is not a whole multiple of the resolution of your data, the nearest multiple of the resolution is used instead. Each bin includes its lower edge and excludes its upper edge; the last bin includes both. The “How this histogram was built” section states the exact width, start and convention used, so the chart can be reproduced.
Match the bin width to the gauge. If the data are recorded to 0.01 mm, use a bin width that is a whole multiple of 0.01. Otherwise some bins can catch two possible readings and others only one, producing a comb pattern that has nothing to do with the process.
Frequency, relative frequency and density
- Frequency — bar height is the count. Best for a single data set.
- Relative frequency — count ÷ n as a percentage. Use it to compare samples of different size.
- Density — count ÷ (n × bin width). The total bar area is 1, so the normal curve is drawn in its natural units and histograms with different bin widths can be compared.
Reading the shape
| Shape | What it usually means |
|---|---|
| Bell-shaped, centred between the limits | Stable process, well centred. Confirm with a capability study. |
| Bell-shaped but close to one limit | Centering problem: adjust the process mean. |
| Wider than the tolerance | Too much variation: the process is not capable. |
| Two peaks (bimodal) | Two streams mixed: machines, cavities, shifts, material lots. |
| Long tail on one side (skewed) | Characteristic bounded on one side, e.g. flatness, runout, roughness. |
| Cut off sharply at a limit (truncated) | Parts have been sorted, or measurements near the limit were “adjusted”. |
| Isolated bars far from the rest | Outliers: measurement errors or special causes. |
| Alternating high and low bars (comb) | Bin width does not match the measurement resolution, or rounding habits. |
Worked example
The sample data are 125 shaft diameters between 24.990 and 25.012 mm with a specification of 25.000 ± 0.018 mm.
Sturges’ rule gives k = ⌈log₂ 125⌉ + 1 = 7 + 1 = 8 bins, so the raw width is range ÷ k = 0.022 ÷ 8 = 0.00275 mm. The nearest “nice” width, 0.0025 mm, is not a whole multiple of the 0.001 mm resolution of the data, so the tool uses 0.003 mm instead: every bin then holds exactly three possible readings. The first bin starts at 24.990, the multiple of 0.003 at or below the minimum, and eight bins cover the data up to 25.014. The counts are 3, 10, 20, 29, 31, 22, 7 and 3.
The histogram is bell-shaped with the mean at 25.0013 mm, slightly above the 25.000 target, and no reading is outside the limits. The next step is to quantify that with the process capability calculator, which reports Cpk = 1.26 for the same data.
Limits of a histogram
- It ignores time. A histogram cannot show whether the process drifted while the data were collected. Use an X̄-R chart or an I-MR chart for that.
- It needs enough data. Below about 30 values the shape depends heavily on where the bin edges fall; 50 to 100 values give a dependable picture.
- The normal curve is not a test. It is drawn from the sample mean and standard deviation as a visual reference. For a formal check run the normality test.
- Observed versus predicted. “Outside spec” here is a count of actual readings. A capable-looking sample of 50 parts cannot demonstrate a defect rate of a few parts per million — that needs a capability analysis.
Frequently asked questions
How many bins should a histogram have?
A common starting point is Sturges’ rule, the base-2 logarithm of the number of values rounded up, plus one: about 7 bins for 50 values, 8 for 100 and 11 for 1,000. Scott’s rule and the Freedman–Diaconis rule set the bin width from the standard deviation or the interquartile range and work better for large or skewed data sets. Adjust the result so that the bin width is a multiple of your measurement resolution.
How do I add specification limits to a histogram?
Enter the lower specification limit (LSL), upper specification limit (USL) and, optionally, the target value in the Specification section. The tool draws them as labelled vertical lines, colours bins that are completely outside the limits and reports the number and percentage of readings below LSL and above USL.
What is the difference between a histogram and a bar chart?
A histogram shows the distribution of one continuous variable: the horizontal axis is a number line divided into adjacent intervals and the bars touch. A bar chart compares separate categories, so the bars are separated and their order is arbitrary. Defect categories belong on a bar or Pareto chart; measurements belong on a histogram.
What is the difference between frequency, relative frequency and density?
Frequency is the count of values in each bin. Relative frequency divides the count by the total number of values, so the bars add up to 100 percent. Density divides the relative frequency by the bin width so that the total area of the bars equals one, which lets you overlay a probability density curve and compare histograms with different bin widths.
Can I upload an Excel file to make a histogram?
Yes. Upload an .xlsx or .csv file, or paste cells directly from Excel or Google Sheets. The file is read by your browser only and is not sent to a server. If the sheet has several columns you can choose which column to plot.
Why does my histogram look like a comb with alternating tall and short bars?
That pattern almost always means the bin width is not a whole multiple of the measurement resolution, so some bins contain two possible readings and their neighbours only one. Set the bin width to a multiple of the smallest increment of your gauge, and start the first bin half an increment below a possible reading if values fall exactly on the bin edges.