Histogram Maker

Group your data into equal bins and draw a histogram, with the frequency table worked out and the bin rule stated: where the bins start, how wide they are, and which bin a value on an edge belongs to. Choose your own bin width or let the tool start from Sturges' rule.

Chart

Data

Type or paste numbers separated by commas, spaces or new lines, or paste a spreadsheet column. Use a point for decimals and leave out thousands separators (1250).30 values read.

Chart and downloads

Heights of 30 bean plants after 3 weeksFrequency0246810121418146151015202530Height (cm)

The PDF has the chart and every step of the working on Letter paper. Print it at 100% or Actual size. Your data stay in this browser.

Titles and labels

What was measured, with its unit: Height (cm)

Histogram settings

Working and PDF

The two agree when there is an even number of values

Worked statistics

Bins and frequencies

Sturges’ rule: log base 2 of 30 is about 4.91; round up to 5 and add 1 to get 6 bins.

Range ÷ 6 = 16.5 ÷ 6 = 2.75, rounded up to a tidy width of 5

The first bin starts at 5, a multiple of 5 at or below the smallest value (9.8).

That gives 5 bins of width 5 instead of the rule’s 6 bins, because the width was rounded up to a tidy value and the first bin starts on a multiple of it.

Each bin includes its left edge but not its right: a value of 20 is counted in the bin that starts at 20.

Frequency table
IntervalFrequencyRelative frequency
5 to under 1013.3%
10 to under 15826.7%
15 to under 201446.7%
20 to under 25620%
25 to under 3013.3%

Total: 30 values. Relative frequency is each frequency ÷ 30, as a percentage (rounded to 1 decimal place).

Sorted data

Sorted values (n = 30): 9.8, 10.7, 11.5, 12.4, 12.9, 13.1, 13.9, 14.2, 14.7, 15.1, 15.6, 15.9, 16.2, 16.5, 16.8, 17.0, 17.3, 17.9, 18.1, 18.6, 18.8, 19.2, 19.9, 20.0, 20.4, 21.3, 21.7, 22.8, 24.6, 26.3

There are 30 values, from 9.8 to 26.3.

Mean

Add the values, then divide by how many there are.

Sum of the 30 values = 513.2

Mean = 513.2 ÷ 30 = 17.11 (rounded)

Median

With 30 values (an even number), the median is the mean of the two middle values, the 15th and 16th.

Median = (16.8 + 17.0) ÷ 2 = 16.9

Mode

Every value appears once, so there is no mode.

Range

Range = largest − smallest = 26.3 − 9.8 = 16.5

Quartiles and IQR (exclusive method)

With 30 values (an even number), split the sorted list into two halves of 15.

Lower half: 9.8, 10.7, 11.5, 12.4, 12.9, 13.1, 13.9, 14.2, 14.7, 15.1, 15.6, 15.9, 16.2, 16.5, 16.8

Q1 = median of the lower half = 14.2

Upper half: 17.0, 17.3, 17.9, 18.1, 18.6, 18.8, 19.2, 19.9, 20.0, 20.4, 21.3, 21.7, 22.8, 24.6, 26.3

Q3 = median of the upper half = 19.9

IQR = Q3 − Q1 = 19.9 − 14.2 = 5.7

What a histogram shows

A histogram summarises a set of measurements by splitting the number line into equal intervals (bins, or classes) and counting how many values fall in each. The NIST/SEMATECH e-Handbook of Statistical Methods describes it this way: frequency (the count for each bin) up the side, the variable along the bottom. The result shows the centre, the spread, the skew and any outliers or second peaks of the data. Histograms are part of Common Core 6.SP.B.4 and of the statistics in England's GCSE Mathematics.

Choosing the bins

The bins decide what the histogram shows. Too few and everything piles into one or two bars; too many and the bars become a ragged row of ones and zeros. Sturges' rule, published in the Journal of the American Statistical Association in 1926, is a common starting point: about ⌈log₂ n⌉ + 1 bins for n values.

Sturges' rule
Values (n)Bins
105
206
306
507
1008
2009
50010
1,00011

The tool divides the range by that number and rounds the width up to a tidy 1, 2, 2.5 or 5 times a power of ten, then starts the first bin on a multiple of the width. With the 30 plant heights below, the rule gives 6 bins, the range ÷ 6 is 2.75 cm, and the tidy width is 5 cm, which makes 5 bins from 5 cm. Tidy edges are easier to read and to draw by hand than exact ones, so the count is often a bin or two away from the rule's, and sometimes further; the working says how many bins you got. You can type any width and starting value instead.

Worked example

Students measured 30 bean plants three weeks after planting, to the nearest 0.1 cm: 12.4, 15.1, 9.8, 18.6, 21.3, 14.7, 16.2, 19.9, 11.5, 17.3, 22.8, 13.9, 16.8, 20.4, 15.6, 18.1, 24.6, 10.7, 17.9, 14.2, 19.2, 16.5, 21.7, 13.1, 18.8, 15.9, 26.3, 17.0, 12.9, 20.0. The tool's histogram and frequency table, worked out when this page was built:

Heights of 30 bean plants after 3 weeksFrequency0246810121418146151015202530Height (cm)
The tool's histogram of the plant heights, in bins 5 cm wide.

Bins and frequencies

Sturges’ rule: log base 2 of 30 is about 4.91; round up to 5 and add 1 to get 6 bins.

Range ÷ 6 = 16.5 ÷ 6 = 2.75, rounded up to a tidy width of 5

The first bin starts at 5, a multiple of 5 at or below the smallest value (9.8).

That gives 5 bins of width 5 instead of the rule’s 6 bins, because the width was rounded up to a tidy value and the first bin starts on a multiple of it.

Each bin includes its left edge but not its right: a value of 20 is counted in the bin that starts at 20.

Frequency table
IntervalFrequencyRelative frequency
5 to under 1013.3%
10 to under 15826.7%
15 to under 201446.7%
20 to under 25620%
25 to under 3013.3%

Total: 30 values. Relative frequency is each frequency ÷ 30, as a percentage (rounded to 1 decimal place).

The tallest bar is 15 to under 20 cm, with 14 plants. The same data in narrower bins show more detail and more noise:

The same plants in 2 cm binsFrequency01234561245654111810121416182022242628Height (cm)
The same heights in 2 cm bins starting at 8 cm.

Values on a bin edge

Every value must count in exactly one bin, so a histogram needs a rule for values that land on an edge. Many US classes write bins as "20 to under 25", which includes the left edge; UK grouped frequency tables are often written as 20 < x ≤ 25, which includes the right edge. The tool does either and says which on the working. With right-edge bins, the plant heights start at 5 cm instead of 5 cm, because a bin that excludes its left edge has to start below the smallest value.

Reading the shape

  • Symmetric: one peak in the middle, falling away evenly on both sides; the mean and median are close.
  • Skewed right: a long tail to the right (incomes, reading times); the mean is pulled above the median.
  • Skewed left: a long tail to the left (scores on an easy test).
  • Two peaks: often two groups mixed together, such as two classes or two plant varieties.

Common mistakes

  • Gaps between bars, which make a histogram look like a bar graph of separate categories.
  • Overlapping intervals such as 10–20 and 20–30 with no rule for 20.
  • Unequal widths with frequency on the axis, which makes wide bins look more important than they are.
  • Labelling the middle of each bar instead of the edges, so readers can't tell where a bin starts.

Frequently asked questions

How many bins should a histogram have?

Enough to show the shape without breaking it into noise. Sturges' rule, a common starting point, gives ⌈log₂ n⌉ + 1 bins: 5 for 10 values, 6 for 20 values, 6 for 30 values, 7 for 50 values. The NIST/SEMATECH e-Handbook notes that classes can be chosen by the user or by a rule; try a couple of widths and keep the one that shows the pattern most clearly.

Which bin does a value on the edge go in?

It depends on the convention, which is why the tool lets you choose and states it. With bins that include their left edge ("20 to under 25"), a value of exactly 20 counts in the 20 to 25 bin. With bins that include their right edge ("over 15 to 20"), it counts in the 15 to 20 bin. UK grouped frequency tables are often written the second way, as 15 < x ≤ 20.

Why are there no gaps between the bars?

The bins are next to each other on a number line: one ends exactly where the next begins, so the bars touch. Gaps belong to bar graphs, whose categories are separate. A gap in a histogram means an empty bin, with no values in it.

Can the bins have different widths?

Not in this tool: it draws equal-width bins, where the height of a bar is its frequency. When bins have different widths, as in some GCSE questions, the height must be the frequency density (frequency ÷ class width) so that the area of each bar, not its height, is proportional to the frequency.

What is the difference between frequency and relative frequency?

Frequency is the count in a bin. Relative frequency is that count divided by the total, often written as a percentage: in the example, the 15 to under 20 cm bin holds 14 of 30 plants. The tool's frequency table gives both.