π Hi!
You're now more than 9000 people reading this newsletter π±. Thank you so much! πππ
β
If you want to share it with a friend, I just put together a (for now, ugly) homepage with all past issues.
As always, todayβs tip is short but powerful. Letβs talk aboutβ¦
β
The problem with legends
Most dataviz libraries make it easy to add legends. That's great! Sometimes, theyβre essential for understanding a chart.
But most of the time? Legends are a hassle.
Take this stacked area chart, for example:
β
β
Reading it means constantly jumping back and forth between the chart and the legend. What does this color mean? Check the legend. What about this one? Check again. And again. π³
Thatβs a lot of unnecessary cognitive load. Instead of absorbing the story, your audience will struggle just to decode the chart. Youβll lose their attention.
So hereβs my advice: If you can remove the legend, remove it.
Solution 1: Direct labeling
Instead of using a separate legend, label the groups directly on the chart.
Line charts / Stacked area charts? Place the labels near the end of the lines. Scatterplots? Find a good spot near the groupβs center. Streamgraphs? Position labels inside the flow where they fit naturally.
Here is an example we've built for the Python Graph Gallery:
β
You see a group, and know instantly what it is! This takes extra effort, but trust me: your readers will thank you.
Technical tip:β
In R, the ggrepel package helps position labels without overlap. In Python, check out drawarrow for easy annotation with arrows.
β
β
βSolution 2: Color in the title
That's another solution: use colors in the title to highlight key categories.
β
This way, you deliver the main message and introduce the groups in one go.
β
Cedric Scherer uses this technique very often. Here is an example with a dumbbell chart from the r graph gallery:
β
β
β
Takeaway
Whenever possible, ditch the legend to make your chart easier to read.
Still skeptical? Check out Dataviz-inspiration.com. Youβll notice that most top-tier visualizations use direct annotation, not legends.
Hope this helps and see you next week!
Yan
β
βPS: this post is a short abstract from the 3rd module of Matplotlib Journey. We just shipped it, and the course is now almost complete π
β
βPPS: I'm working on a tool allowing to create a homepage like mine in less than 30 minutes. Would you like to beta-test it? Hit reply!
β
π By the way, there are 3 ways I can help you!
- Consulting: I help my clients design and create interactive dataviz webpages to make their data alive
- Online Courses: 2000+ ppl already followed my in-depth, interactive learning experiences about R, matplotlib, ggplot2 and d3.jsβ
- Engaging Talks: I'm deeply passionate about tech and dataviz. Hire me for a talk or a training!
Check yan-holtz.com or hit reply any time!
|
|
β