This week, I'm writing the third module of my Matplotlib Journey project, and it's about a crucial yet often neglected part of data visualization:
β
π Annotation βοΈ
β
I like to think of annotations as what your chart would say if it could talk. Essentially, explaining to the reader what they need to understand.
There are 2 main use-cases for annotations:
β
1οΈβ£ Annotation to Provide Context
Letβs say you need to build a bubble plot showing the relationship between GDP per capita and life expectancy.
With a few lines of R code, you get something like this:
Bubble chart made with R. Source and code on data to vizβ
Not too bad! π β The message is clear, and the trend is obvious.
But how frustrating is it not to know which country each dot represents? Some circles are clearly out of the trend. It drives me crazy not to know who they are!
Thatβs where annotations become essential. A bit of text here and there can turn a good chart into a great one:
Same graph, but with annotation
Depending on your story, it's up to you to decide which countries to highlight to guide the reader and help them understand the message.
This graph is a connected scatterplot. It illustrates the evolution of both troop numbers and the army budget.
Without annotations, the message would be unclear, but with them, the chart tells a complete and compelling story!
2οΈβ£ Annotation to Highlight a Result
Annotations can also be used to draw attention to the specific part of the chart that tells the main story.
They don't add extra information, but they make the key result stand out, ensuring your message comes across clearly.
Hereβs an example from the Python Graph Gallery:
Abstract of a chart by Joseph Barbier, code in the gallery.
The full chart is quite dense and could easily overwhelm the reader.
However, the annotations ensure the key points stand out, keeping the reader focused and engaged.
Conclusion
The takeaway from this post is simple yet fundamental: next time you present a graph in a report, paper, or presentation, add some annotations!
Otherwise, chances are you could make the graph more effective.
For a few years now, Iβve been collecting all the data visualization projects I love on Dataviz-inspiration.com. Check it out! Youβll see that about 90% of the projects include lots of annotations.
See you next week for another dataviz tip!
β
Yan
PS: If you add an annotation to your chart this week, send me a screenshot! Itβll make my day! You can find me on LinkedIn and Bluesky.
PPS: There are now 283 students enrolled in Matplotlib Journey π±. And weβre only halfway through writing it! Thank you so much for your trust and support! π β