Distribution plots, and the dynamite plot
A bar chart with one error bar hides the sample size, the shape of the distribution and the outliers, and that bar may be an SD, an SE or a 95% CI — lengths that differ several-fold. What the box plot, the violin and the raincloud each add back, and why journals have started asking for every data point.
What this page is about
The commonest way a continuous outcome is drawn in papers and slides looks like this: one bar per group, the height is the mean, and a short whisker sticks out of the top. The picture has a nickname — the dynamite plot, because it looks like a stick of dynamite with a fuse.
The problem is not that it is ugly. The problem is that it draws two numbers per group: one bar height and one whisker length. You started with tens or hundreds of observations, and the reader ends up with two summaries and no way of telling how many people they were computed from.
This page draws one dataset four ways, and then works out exactly what the first of those four threw away.
The data are MASS::birthwt: 189 mothers, with birth weight in grams as the outcome. The grouping
variable is the same one the ANOVA example uses on
t-tests and analysis of variance, so the two pages describe the same
strata of the same dataset.
One dataset, four ways to draw it
figures/scripts/B1-05-distribution-plots.RWhat each of the four hands the reader, and what it withholds:
| Plot | The reader gets | The reader does not get |
|---|---|---|
| Bar chart with error bars | The mean, and a whisker of undefined meaning | Sample size, spread, shape, outliers, individual observations |
| Box plot | Median, interquartile range, whisker range, flagged outliers | Sample size, bimodality, the density inside the box |
| Violin plot | The whole density shape, bimodality, long tails | Sample size, individual observations (a density is an estimate, not the data) |
| Raincloud | Density shape, quartiles, every observation, sample size | Nothing — its cost is page space, not information |
Look at the vertical axis of panel A. For bar lengths to be comparable, the axis has to start at zero, so the data end up squeezed against the top of the plot. The other three are under no such constraint: their axes can sit on the data, which buys a great deal of resolution on the same piece of paper.
What the dynamite plot hides in this dataset
The table above states principles. Principles do not convince anyone, so this section computes the numbers.
One: the group sizes differ several-fold, and the bar chart shows none of it
| Group | n | Mean (g) | SD (g) | SE (g) | Median (g) | IQR (g) |
|---|---|---|---|---|---|---|
| White | 96 | 3102.7 | 727.9 | 74.3 | 3062 | 1066.2 |
| Black | 26 | 2719.7 | 638.7 | 125.3 | 2849 | 686.5 |
| Other | 67 | 2805.3 | 722.2 | 88.2 | 2835 | 961 |
The largest group is 3.69 times the size of the smallest, while the three SDs are almost identical — largest over smallest is 1.14. Yet the three SE whiskers differ in length by a factor of 1.69. The reason is that SE is the SD divided by the square root of n, so the length of the whisker is mostly reporting sample size, not spread.
This dataset supplies an unusually clean example. The Black group has the smallest SD of the three (638.7 g), and the longest SE whisker of the three (125.3 g), because it contains only 26 mothers.
Two: the means look far apart, the individual babies overlap heavily
| Comparison | Difference in means (g) | P(a random baby from the first is heavier) | Share of the first inside the second’s IQR | Overlap of the two ranges (g) |
|---|---|---|---|---|
| White vs Black | 383 | 0.654 | 30.2% | 1135 to 3860 |
| White vs Other | 297.4 | 0.606 | 42.7% | 1021 to 4054 |
| Black vs Other | -85.6 | 0.459 | 53.8% | 1135 to 3860 |
The first row is the representative one. The White and Black groups differ in mean birth weight by 383 grams, which on a bar chart is two visibly different heights. But draw one baby at random from each group, and the probability that the White one is heavier is only 0.654 — better than a coin flip, nowhere near two separate populations. And 30.2% of the White babies weigh something that falls inside the Black interquartile range.
That quantity — the probability of superiority — earns its place because it is free of the original units and because every reader already knows what 0.5 means. It is not a test, and it does not replace the inference on ANOVA and its post hoc comparisons. It answers a different question: how large is this group difference when it is applied to one patient.
Three: shape — these data are actually rather clean, and saying so is more useful
At this point a textbook usually adds that the bar chart also hid the skew, the bimodality and the outliers. In this dataset that sentence is mostly untrue, and reporting it honestly beats reciting the principle:
| Group | Skewness | Outliers under the 1.5 IQR rule | Local density maxima (default bandwidth) | Local density maxima (bandwidth widened by half) |
|---|---|---|---|---|
| White | -0.13 | 0 | 3 | 1 |
| Black | -0.31 | 1 | 3 | 1 |
| Other | -0.42 | 1 | 2 | 1 |
The largest absolute skewness of the three groups is only 0.42, which is close to
symmetric, and of all 189 babies the 1.5 IQR rule flags 2. As for
bimodality: at the default bandwidth of density(), the worst group has 3 local
maxima and looks as though it contains a second cluster; widen the bandwidth by half and all three groups drop
to 1. The extra peaks are a product of the smoothing parameter, not evidence of
subpopulations.
So in this dataset the damage a dynamite plot does comes from unequal group sizes and from overlap, not from hidden skew or hidden modes. What happens when the shapes genuinely do differ is section five, on data constructed for the purpose.
Three error bars, identical in appearance, several-fold apart in length
The phrase “that error bar” keeps recurring above because the plot itself does not say which one it is. The same data support three:
- SD (standard deviation) describes how spread out the individuals are. It does not shrink with sample size — recruit a hundred more people and the SD is about the same.
- SE (standard error) describes how precisely the mean has been estimated. It is the SD divided by the square root of n, so it shortens as the sample grows.
- 95% CI is the SE multiplied by a t quantile, roughly two SEs. It answers where the mean plausibly lies.
figures/scripts/B1-05-distribution-plots.R| Group | SD half-length (g) | SE half-length (g) | 95% CI half-length (g) | SD as a multiple of SE | CI as a multiple of SE |
|---|---|---|---|---|---|
| White | 727.9 | 74.3 | 147.5 | 9.8 | 1.99 |
| Black | 638.7 | 125.3 | 258 | 5.1 | 2.06 |
| Other | 722.2 | 88.2 | 176.2 | 8.19 | 2 |
In the White group the SD bar is 9.8 times as long as the SE bar. The same data and the same mean, and the reader sees a picture that differs by nearly an order of magnitude depending on which one the author picked. The SE is the shortest of the three, so choosing it makes the groups look as separated as they can possibly look — which is part of why it is chosen so often.
There is a related misreading: whether two error bars overlap is not a substitute for a test. Two 95% CIs can overlap slightly while the test of the difference in means still reaches statistical significance, and two SE bars can fail to overlap without it reaching significance. What settles a group comparison is the confidence interval of the difference, not whether two separate intervals happen to touch. t-tests and analysis of variance covers this properly.
One bar chart, three completely different datasets
Section three said it plainly: the three birthwt groups are fairly symmetric with almost no outliers. So
what does happen when the shapes really do differ? The three samples below are constructed on purpose and
are not the result of any study: each has 40 observations, a mean of 3000 and
an SD of 700, so the SE is 110.7 for all three and the 95% CI half-length is
223.9 for all three. Their bar chart is one picture drawn three times.
figures/scripts/B1-05-distribution-plots.R| Constructed sample | Mean | SD | SE | Median | Skewness | Outliers | Density peaks |
|---|---|---|---|---|---|---|---|
| Sample 1: symmetric, one mode | 3000 | 700 | 110.7 | 3000 | 0 | 0 | 1 |
| Sample 2: two clusters | 3000 | 700 | 110.7 | 3000 | 0 | 0 | 2 |
| Sample 3: four extreme values | 3000 | 700 | 110.7 | 2831.8 | 1.95 | 4 | 3 |
The first four columns are identical and the last four are nothing alike. Sample 2 splits into two clusters and its mean falls in the gap between them, where nobody is — a position no observation comes near, and the height of the bar. Sample 3 has a skewness of 1.95, and its 4 extreme values drag the mean from a median of 2831.8 up to 3000.
Run it yourself
library(MASS)
data(birthwt, package = "MASS")
bw <- birthwt
bw$race_f <- factor(bw$race, levels = 1:3, labels = c("White", "Black", "Other"))
sp <- split(bw$bwt, bw$race_f)
# 1. Bar chart with SE whiskers. Here for comparison, not as a recommendation.
m <- sapply(sp, mean)
se <- sapply(sp, function(x) sd(x) / sqrt(length(x)))
mids <- barplot(m, ylim = c(0, 3600), ylab = "Birth weight (g)")
arrows(mids, m, mids, m + se, angle = 90, code = 2, length = 0.05)
# 2. Box plot. One line.
boxplot(bwt ~ race_f, data = bw, ylab = "Birth weight (g)")
# 3. Violin plot: density() + polygon(), no extra package needed.
violin <- function(x, at, width = 0.35, col = "#dfe6ee") {
d <- density(x, adjust = 1.2)
k <- d$x >= min(x) & d$x <= max(x) # do not draw beyond the data
dy <- d$y[k] / max(d$y) * width
polygon(c(at + dy, rev(at - dy)), c(d$x[k], rev(d$x[k])), col = col)
}
plot(NA, xlim = c(0.5, 3.5), ylim = range(bw$bwt), xaxt = "n",
xlab = "", ylab = "Birth weight (g)")
axis(1, at = 1:3, labels = levels(bw$race_f))
for (i in 1:3) violin(sp[[i]], i)
# 4. Raincloud: half a violin, a narrow box, and every observation.
plot(NA, xlim = c(0.5, 3.5), ylim = range(bw$bwt), xaxt = "n",
xlab = "", ylab = "Birth weight (g)")
axis(1, at = 1:3, labels = levels(bw$race_f))
set.seed(1) # without a fixed seed the points move
for (i in 1:3) {
x <- sp[[i]]
d <- density(x, adjust = 1.2)
k <- d$x >= min(x) & d$x <= max(x)
dy <- d$y[k] / max(d$y) * 0.34
polygon(c(rep(i, sum(k)), rev(i + dy)), c(d$x[k], rev(d$x[k])),
col = "#dfe6ee", border = "#4d6a8c")
boxplot(x, at = i - 0.02, add = TRUE, boxwex = 0.09,
axes = FALSE, outline = FALSE)
points(jitter(rep(i - 0.22, length(x)), amount = 0.09), x,
pch = 16, cex = 0.6, col = adjustcolor("#4d6a8c", 0.4))
text(i - 0.22, min(bw$bwt), paste0("n = ", length(x)), cex = 0.8)
}Verified on R 4.6.0 with MASS 7.3.65. All four plots are base R and need nothing installed — the position of this page is that drawing something better than a bar chart requires no new tools at all. Always fix the seed for the jittered points, or the same data will scatter differently every time you redraw.
import matplotlib.pyplot as plt
import seaborn as sns
import statsmodels.api as sm
bw = sm.datasets.get_rdataset("birthwt", "MASS").data
bw["race_f"] = bw["race"].map({1: "White", 2: "Black", 3: "Other"})
# Box plot and violin plot, one line each
sns.boxplot(data=bw, x="race_f", y="bwt")
sns.violinplot(data=bw, x="race_f", y="bwt", inner=None, cut=0)
# A raincloud has to be stacked by hand: half violin, narrow box, jittered points
fig, ax = plt.subplots(figsize=(6, 4))
sns.violinplot(data=bw, x="race_f", y="bwt", inner=None, cut=0,
split=True, hue=1, legend=False, ax=ax)
sns.boxplot(data=bw, x="race_f", y="bwt", width=0.08, showfliers=False,
boxprops={"zorder": 3}, ax=ax)
sns.stripplot(data=bw, x="race_f", y="bwt", size=3, alpha=0.45,
jitter=0.18, dodge=False, ax=ax)
ax.set_ylabel("Birth weight (g)")
# Group sizes have to be added yourself; seaborn will not print them
for i, (lab, grp) in enumerate(bw.groupby("race_f", sort=False)):
ax.text(i, bw["bwt"].min(), f"n = {len(grp)}", ha="center", fontsize=8)matplotlib and seaborn both have boxplot and violinplot, but neither ships a raincloud; the version below stacks violinplot, boxplot and stripplot by hand.
Journals have started asking for the individual data points
This is no longer a matter of taste; it has reached submission guidelines.
Weissgerber and colleagues surveyed papers in leading physiology journals for PLOS Biology (2015) and found that the great majority presented continuous data as bar charts with error bars, often at sample sizes so small that the two summaries meant very little. Their central argument is the figure in section five above: one bar chart is compatible with many datasets that look nothing like each other.
What has changed since:
- The PLOS Biology submission guidelines recommend presenting continuous data so that the reader can evaluate the distribution — scatter plots, box plots, histograms — and require the full distribution to be shown, rather than summary statistics alone, for small samples (9 or fewer independent observations per group).
- eLife requires figure legends to state the sample size and the definition of the error bars, along with the statistical tests and the replicates. That is the previous section’s problem written into a rule.
- A growing number of journals discourage bar charts for continuous outcomes in their figure guidance.
The practical rule of thumb is short:
- Fewer than about twenty observations per group — plot every point (a dot plot or a raincloud); do not summarise.
- Tens to a few hundred per group — a box plot or a violin, better still with sampled points on top.
- Thousands per group — points turn into a smear; use a violin or a histogram, and put the sample size on the figure.
- Always — say in the caption what the error bar is and what the sample size was.
When a bar chart is the right choice
The bar chart is not a bad plot; it is a plot used in the wrong place. Its proper job is counts and proportions: how many people, or what share, fall in each level of a categorical variable. There the bar length starts at zero, genuinely means “how many”, and is both additive and comparable. That case is covered in the chi-squared test and comparing proportions.
For a continuous outcome, even if all you want is the summary, two options beat a bar chart:
- Plot the mean and its confidence interval as a point with an interval, with no bar. The bar itself carries no information while consuming the whole vertical axis.
- For a skewed variable, report the median and the IQR instead. Which of the two to report is decided in the “mean or median” section of Table 1 and the standardised mean difference.
Common misuse
| Misuse | Why it is wrong |
|---|---|
| Drawing a continuous outcome as a bar chart with error bars | Two numbers per group survive; sample size, shape, outliers and individual observations are gone |
| A caption that says “error bars” without saying which kind | SD, SE and 95% CI look identical on the page and differ several-fold in length |
| Choosing SE so that the groups look further apart | SE is the shortest of the three, and it describes the precision of the mean, not the spread of individuals |
| Reading a longer whisker as a less consistent group | SE length is driven mainly by sample size, and in this dataset the direction is reversed |
| Using overlap between two error bars in place of a test | What settles it is the interval for the difference, not whether two separate intervals touch |
| Very unequal group sizes that are never stated | The reader cannot tell which bar rests on a stable estimate |
| Claiming two subgroups because a violin has two bulges | Peak counts move with bandwidth; all three groups here drop to one peak once it is widened |
| Reading a large difference in means as a large difference for individuals | The probability of superiority here is only 0.654 |
| Concluding “no difference between the groups” because the error bars overlap | Only that this figure does not show separation; claiming equivalence needs a non-inferiority design and a pre-specified margin |
| Switching categorical counts to violin plots as well | Counts and proportions belong on a bar chart; do not over-apply this page |
Rerun every number on this page
/opt/homebrew/bin/Rscript figures/scripts/B1-05-distribution-plots.RRead the figure
The answer comes from the same statistical output that produced this page's figures, not from a number typed in beside them.
On the dynamite plot, the smallest group (26 babies) carries the longest of the three error bars. Does that mean birth weights in that group are the least consistent?
Show the answer and why
Correct answer: No. That group has a standard deviation of 638.7 grams, the smallest of the three - a standard error is the standard deviation divided by the square root of the group size
The three standard deviations are nearly identical, differing by less than a fifth between the largest and smallest, yet the three standard-error bars differ in length by a factor of 1.7. This group is the cleanest example: its standard deviation of 638.7 grams is the smallest of the three while its standard error is the longest, because it holds only 26 people. So the visual impression of which whisker is longer is not saying that group is less consistent, it is saying that group is smaller - an illusion that reverses direction rather than merely distorting degree. The 258.0 is the confidence interval half-length for the same group, roughly twice the standard error, and switching which error bar you draw changes none of the above: all three look identical on the plot and only the caption tells them apart.
The White and Black groups differ by 383 grams in mean birth weight, two visibly different bar heights on the chart. How large is that group difference when it is brought down to a single patient?
Show the answer and why
Correct answer: Draw one baby at random from each group and the chance the first is heavier is 0.654 - a little better than a coin toss
The probability of superiority, 0.654, is free of the original units and every reader knows what a half means, so it answers precisely the question of how large this group difference is for one patient: a little better than a coin toss. 0.302 really is the share of the first group falling inside the interquartile range of the second, but a low share does not mean the groups barely overlap, since an interquartile range covers only the middle half of a group and falling outside it is the norm - the two ranges of values in fact intersect from about eleven hundred grams up to about thirty-eight hundred. 0.462 is the same kind of proportion in the other direction, and it describes overlap rather than the size of the difference. Large-looking gaps between group means alongside heavy overlap between individuals is exactly where bar charts mislead, and this quantity is not a test and does not replace the inference that ANOVA and post hoc comparisons perform; it answers a different question.
One group of data yields error bar half-lengths of 727.9, 74.3 and 147.5 grams depending on the definition, and the caption says only error bars. Can this figure be read?
Show the answer and why
Correct answer: No. The standard deviation bar is 9.8 times the length of the standard error bar, so identical data with an identical mean produces figures an order of magnitude apart
All three error bars look identical on the plot and only the caption separates them, while their lengths differ by nearly an order of magnitude: the standard deviation bar is 9.8 times the standard error bar. So when the caption does not say which one it is, that panel counts as unread - not read imprecisely, but unreadable. Recovering the answer from relative lengths cannot be done from a single figure, because the reader has no other two bars to compare against; a confidence interval is indeed about 2.0 times a standard error, but only once you already know both are drawn. And 74.3 is the shortest of the three, which is precisely why it is chosen so often: the shortest bar makes the groups look furthest apart. One related misreading: whether error bars overlap is not a substitute for a test, because judging a group difference means looking at the confidence interval of the difference itself, not at whether two separate intervals touch.
Three deliberately constructed samples share the same size, mean and standard deviation, so their bar charts are one chart drawn three times, with the bar sitting at 3000 grams in all three. In which sample does that bar height fall where no observation comes near it?
Show the answer and why
Correct answer: The one with 2 density peaks - two groups of people sitting either side of the bar, the stretch between them empty, and the mean landing in that gap
The size, mean, standard deviation and standard error are identical across all three, so the bar chart really is one picture, and everything that differs is invisible on it. The median of 2832 grams in the sample with four extreme values has indeed been pulled away from 3000, but a mean that differs from the median is not a mean with nothing near it - that sample runs in one unbroken stretch and its closest observation sits almost exactly on the bar height. What is wrong there is that the bar cannot stand for a typical patient, not that it sits on empty ground. The symmetric sample is more direct still, because symmetric is not flat - it has a single mode, its density is highest precisely at the bar height, and it is the only one of the three whose bar chart tells the truth. The sample that does sit on empty ground is the one with two density peaks, where two populations gather either side, the five hundred grams between them hold nobody, and the mean lands in that gap. The answer to that shape is not a different chart but going back to ask whether this group is really one group - responders and non-responders, two subtypes, two centres recruiting differently - and the chart only gives you the chance to ask.
At the default bandwidth the density curves for these three groups show up to 3 local maxima, which looks like subgroups; widen the bandwidth by half and all three are left with 1. What should you conclude?
Show the answer and why
Correct answer: The extra peaks are an artefact of the smoothing parameter. Widening leaves 1, and how many peaks a density has is a property of the bandwidth you chose, not of the data
When a violin plot in a paper shows two bumps, the question to ask before concluding anything is what bandwidth the author used - and most papers do not say. This data is the example: at the default bandwidth the busiest group has three local maxima, and widening by half leaves every group with one. A default is an empirical formula rather than a conclusion about the data, so it cannot serve as evidence that a subpopulation exists; conversely, widening the bandwidth is not erasing a signal, it is asking whether the peak survives. The count of observations flagged as outliers shows this data is fairly clean, but that has nothing to do with reading the peaks. It is also another reason raincloud plots draw the individual points: once the points are visible, the reader need not trust any smoothing parameter.
A reviewer says that recruiting another hundred patients will shorten the error bars and make the figure more convincing. For which kind of error bar is that true?
Show the answer and why
Correct answer: True only of the standard error and the confidence interval. The standard error of 74.3 grams is the standard deviation divided by the square root of the group size
A standard deviation describes how spread out individuals are, a property of the people themselves: recruiting another hundred patients makes the estimate steadier but leaves the value much where it was, 727.9 grams for this group. A standard error describes how precisely the mean has been estimated, equal to the standard deviation divided by the square root of the group size, so it shortens as the group grows - 74.3 grams here - and the confidence interval, about twice as long, shortens with it. The 3.7 is the ratio of the largest group to the smallest, and it does explain why the three standard-error bars differ in length, but it does not move the standard deviations, which are nearly identical across the three groups. The phrase about the figure looking more convincing deserves its own suspicion: the error bar that makes groups look furthest apart is precisely the shortest one.
Chapters that use this method
Sources and licences
- Beyond Bar and Line Graphs: Time for a New Data Presentation ParadigmCC BYThe argument that a bar chart shows only two numbers per group, and that one bar chart is compatible with many completely different datasets, is from Weissgerber et al. (PLOS Biology 2015), as is the case for journals requiring individual observations to be plotted. Every number on this page was computed here on MASS::birthwt.
- Raincloud plots: a multi-platform tool for robust data visualizationCC BYThe raincloud (half violin plus box plus individual points) and its name come from Allen et al. (Wellcome Open Research 2019). The implementation here was rewritten from scratch with base R density() and polygon(); none of their code is used.