❌ Don't use a legend (do this instead)


👋 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!

Yan Holtz

Find me on X, LinkedIn, or check my Homepage

👋 By the way, here is how I can help!

  • Master R: Join my productive R workflow online course, already helping hundreds to excel in R, Quarto, and GitHub.
  • Team Training: Hire me to train your team on Data Visualization and Programming.
  • Engaging Talks: Book me for short, impactful talks on Data Visualization and Programming.

Check yan-holtz.com or hit reply any time! I love hearing from you.

https://preview.convertkit-mail2.com/unsubscribe
Unsubscribe · Preferences

background

Subscribe to Dataviz Universe