Lesson 8 of 20
Four ways to show a distribution — histogram, box, violin, points
why Figs. 2B and 2D chose the violin
TIL infiltration for 480 patients. Real TCGA lung adenocarcinoma data.
patients480
1st quartile2.60%
median5.67%
3rd quartile14.28%
max55.8%
mean9.90%
The mean is 1.7 times the median — the distribution has a long right tail. Write “mean 9.9%” on a single bar and all of that disappears.
Look only at the leftmost bar and every patient seems to sit near 10%. In fact some are at 0% and some at 55%.
Python
Runs in your browser
What each of the four shows and hides:
| Shows | Hides | Use when | |
|---|---|---|---|
| Bar + error | the mean, one spread | shape · number of modes · outliers | only when n is very large |
| Histogram | the whole shape | individual values · group comparison | examining one group closely |
| Box | five numbers · outliers | bimodality | comparing several groups |
| Violin | shape + group comparison | exact counts | when every group has a large n |
DDX54's two groups are slightly offset; CD8A's separate cleanly. Making the degree of overlap visible is what a violin is worth.
Python
Runs in your browser
🤔 Check yourself
You have four conditions with n = 6 each. What is the most honest chart?
Answer Below about ten observations, showing them all is the honest thing. A violin estimates a density, so with small n it invents shapes that are not there.
🤔 Check yourself
A distribution has mean 9.9% and median 5.7%. What follows?
Answer A mean above the median means the upper tail is pulling it up. Some patients really are at 55%. Reporting only 'mean 9.9%' loses half the story.
🤔 Check yourself
What does a box plot miss?
Answer A box summarises with five numbers, so it cannot show how many modes there are. Two peaks usually signal a hidden subgroup — and that signal disappears.