Visualizing Data
A good chart shows you quickly what a table of numbers hides. The most useful chart for one quantitative variable is the histogram. It has one setting, the bin width, that can reveal a distribution's true shape or completely distort it.
What a histogram shows
A histogram divides the number line into equal-width bins and draws a bar showing how many values are in each. Unlike a bar chart (which compares separate categories), a histogram's bars touch, because they cover a continuous range. At a glance it shows three things about a distribution: its shape (symmetric and bell-like, skewed to one side, or with multiple peaks), its center (roughly where the values pile up), and its spread (tightly clustered or widely scattered). It also shows whether any outliers are stranded out in the tails.
🎮 The Bin-Width Dial
Same data, different number of bins. Too few bins hides the shape; too many turns it into noise. Find the bin count that shows the real shape.
The bin-width lesson: with only 2–3 bins, a two-peaked distribution looks like a single blob, its structure smoothed away. With 50+ bins, even bell-shaped data looks jagged and random. The right number of bins (often somewhere around 10–20 for a few hundred points) shows the shape without adding false detail. Always try a couple of bin widths before you trust a histogram.
How wide should a bin be?
Statistics also has three standard rules for choosing the width, and your plotting software already uses one of them:
- Sturges' rule sets the number of bins rather than their width:
k = ⌈log₂ n⌉ + 1. It's the oldest of the three and assumes an idealized bell. - Scott's rule sets a width from the standard deviation:
h = 3.49 s / ∛n. - Freedman–Diaconis swaps that standard deviation for the interquartile range:
h = 2 × IQR / ∛n. Because the IQR ignores the tails, one wild value can't stretch every bin in the plot.
Run all three on the bell shape above (400 observations, SD near 13, spread across roughly 80 points of the scale) and they give 10, 13 and 17 bins. The slider starts at 12, inside that range, so the first picture already looks sensible. Spreadsheet software often uses a fourth rule, the square-root rule (√n bins), which is cruder but rarely badly wrong.
Now switch the shape to two peaks and run the rules again. Scott and Freedman–Diaconis both drop to 9 bins, fewer than they gave for the bell, because the gap between the humps inflates both the SD and the IQR. The rules use only the spread, not the shape. Here the peaks are far enough apart to stay visible with the coarser bins, but with closer peaks the same rules could hide them. So check the shape yourself by moving the slider.
Other common charts
- Bar chart. For categorical data: one bar per category, with gaps between them (the categories aren't a continuum).
- Boxplot. The median, the quartiles, and whiskers reaching as far as the most extreme value still within 1.5 × IQR of the box. Anything beyond is drawn as its own point, so a boxplot flags outliers, and several boxplots line up well side by side. Every boxplot on this page computes its quartiles the way R and Python do, by interpolating between neighboring values. §1.3 compares that convention with the textbook one you would use on paper, and the descriptives calculator will draw the box either way.
- Scatterplot. For two quantitative variables at once; the starting point for correlation and regression.
Which of the three you can draw depends on your variables. For one categorical variable, use a bar chart of counts. For one quantitative variable split by a categorical one, use boxplots side by side. For two quantitative variables, use a scatterplot. The survey below supports all three: for each student in a class, it records the revision method they relied on most, the hours they studied, and their score.
🎮 One Survey, Three Charts
The same students drawn three ways. Switch the chart, then use the checkbox to add the thing that display usually leaves out.
One categorical variable. Bar heights are counts of students, and the gaps show that the four methods are separate categories, not points on a scale.
Each view shows one thing and leaves out another. The bar chart counts students and says nothing about how any of them did. The boxplot compares the four groups, but it draws much the same box whether a group's scores gather around one value or split into two clusters, so switch the raw scores on to check. The scatterplot keeps every student on screen but hides the group comparison until you color the dots. Then reduce the survey to 16 students. Most of the patterns you could see a moment ago are no longer clear.
For your own dataset, the Which Chart Should I Use? chooser leads you to the right display in a few clicks. When the chart is going into a paper, Tables & Figures That Don't Lie shows how to avoid a misleading figure.
Why it matters: plot your data before you compute anything. The shape determines which summaries are appropriate (mean or median) and which tests are valid. Once you have looked, the test chooser turns what you saw into a shortlist of tests.
Common questions
I only have 15 data points. Is a histogram still the right picture?
Sturges' rule asks for 5 bins at n = 15. In 50,000 simulated samples of 15 drawn from a perfect bell, 62% of those histograms showed a dip with a taller bar on either side of it: a second peak that does not exist in the population. At n = 400 with 10 bins that false pattern appears 11% of the time, so at 15 the histogram mostly shows where the bin edges happened to fall. Show every observation instead. A dot plot or strip plot puts one mark per value along the axis, and a boxplot with the raw points drawn over it gives you the summary and the evidence at once. The descriptives calculator will also list the numbers, and for 15 values a plain list is a perfectly good figure.
Why do people say never to use a pie chart?
Because pie charts make readers judge angles and areas, which humans do poorly — classic perception experiments (Cleveland & McGill, 1984) show we compare aligned bar lengths far more accurately. With more than two or three slices, "which is bigger?" becomes guesswork that a sorted bar chart answers instantly. The defensible pie is rare: a single part-of-whole message with two or three very different slices. Our chart chooser has a whole "resist the pie" verdict explaining the alternatives.
When should I use a boxplot instead of a histogram?
Use a boxplot when comparing several groups side by side (five boxplots fit neatly where five histograms would be a mess), or when you want outliers flagged automatically by the 1.5 × IQR rule. Use a histogram when the shape matters (skew, two peaks), because a boxplot can't show bimodality. Our descriptives calculator draws both from pasted data.