Motivation

Every single tutorial or course I took did not care to spend more than 10 minutes to explain how to control annotations in Matplotlib. If I googled the topic, the first 5 or 6 links are all from Matplotlib documentation, the rest are just slightly altered versions of it 🤦‍♂️.

While I was writing an article about styling plots, I realized that the topic was too big to fit into a single section. I gave a brief intro there and decided to write a separate article. So, here I am, teaching how to annotate any plot in a fully controlled manner in less than 9 minutes. Enjoy!

Overview

  I. Motivation

 II. Setup
III. Basic Text Control
 IV. Moving Text While Keeping the Reference Point
  V. Pointing With Arrows
 VI. Putting a Box Around Text
VII. Getting Fancy, Annotating a Line Plot

Get the full code and sample data on this GitHub repo.

#programming #data-science #python #machine-learning #artificial-intelligence

Master `plt.annotate()` to take your plots to the next level
1.25 GEEK