0
0
Matplotlibdata~30 mins

Why annotations tell the data story in Matplotlib - See It in Action

Choose your learning style9 modes available
Why annotations tell the data story
📖 Scenario: Imagine you are a data analyst presenting sales data to your team. You want to highlight important points on your sales chart so everyone understands the story behind the numbers.
🎯 Goal: You will create a simple sales line chart and add annotations to explain key points. This will help you learn how annotations make data easier to understand.
📋 What You'll Learn
Create a dictionary called monthly_sales with exact sales data for 6 months
Create a list called months with the month names in order
Create a matplotlib line plot of sales over months
Add at least two annotations to highlight important sales points
Display the plot with annotations
💡 Why This Matters
🌍 Real World
Annotations help explain charts in reports or presentations so viewers quickly understand key insights.
💼 Career
Data analysts and scientists use annotations to communicate findings clearly to non-technical audiences.
Progress0 / 4 steps
1
Create the sales data
Create a dictionary called monthly_sales with these exact entries: 'Jan': 150, 'Feb': 200, 'Mar': 180, 'Apr': 220, 'May': 210, 'Jun': 230. Also create a list called months with these exact values in order: 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'.
Matplotlib
Need a hint?

Use curly braces {} to create the dictionary and square brackets [] to create the list.

2
Prepare the sales values for plotting
Create a list called sales_values that contains the sales numbers from monthly_sales in the order of the months list.
Matplotlib
Need a hint?

Use a list comprehension to get sales values in the order of months.

3
Create the sales line plot with annotations
Import matplotlib.pyplot as plt. Create a line plot using months on the x-axis and sales_values on the y-axis. Add two annotations: one at 'Feb' with text 'Sales jump' pointing to the point, and one at 'Apr' with text 'Peak sales' pointing to the point.
Matplotlib
Need a hint?

Use plt.plot() to create the line chart and plt.annotate() to add text with arrows.

4
Display the plot
Use plt.show() to display the plot with the annotations.
Matplotlib
Need a hint?

Call plt.show() to open the plot window.