First, a quick apology for missing last week's email. 😔
It’s the first time this year I’ve skipped one, but with over 450 people joining the launch of ggplot2 uncharted, things got a little intense on my end.
Anyway, let's go back to our usual, short & actionnable dataviz tip with a few words about bubble size.
🫧 Why bubbles?
Circles are everywhere in dataviz.
In scatterplots, their position usually encodes two variables (x and y). But sometimes, we also use their size to encode a third.
That’s when circles become bubbles.
A classic example is Hans Rosling’s iconic animated bubble chart. His TED Talk (now with over 4 million views on YouTube) is a must-watch for anyone interested in data storytelling. It’s a dataviz classic.
Repro of this famous bubble plot using R and plotly. code.
But bubbles aren’t just for scatterplots! They’re also the core of circle packing, standalone indicators in dashboards, or can be used in conjunction with circular barplots, dendrograms or lollipop! Here are a couple of examples taken from my dataviz inspiration project:
Authors: R vignette, Evelina Parrou, Léa Desrayaud, Nadieh Bremer.
⚠️ Value ≠ Radius
A common mistake is mapping a value directly to the radius of a circle. This is misleading, because a circle’s area grows with the square of its radius!
So if you double the radius, the area, and thus visual impact, quadruples.
This distorts perception and overemphasizes large values.
🛠️ How to do it right?
In R / ggplot2: You're safe! size in the aesthetics call handles area scaling automatically.
In Python / Matplotlib: Use the s= argument, but remember it expects area so you might have to square the values!
In D3.js: Be extra careful. Use scaleSqrt() when sizing circles. Many mistakenly use scaleLinear(), which overstates large values.
That’s it for today! I hope next time you draw a circle you'll keep this in mind!
Have a wonderful day,
Yan PS: Cédric Scherer and I are deep into writing ggplot2 Uncharted. If there’s anything about ggplot2 you find confusing or unclear, let me know! We would love to write about it.