Highlighting Date Ranges
📖 Scenario: You work as a data analyst for a company that tracks daily sales over a month. You want to visually highlight a specific date range on the sales chart to show a promotional period.
🎯 Goal: Create a line chart of daily sales and highlight the sales during the promotional date range using a shaded area.
📋 What You'll Learn
Create a dictionary called
sales_data with dates as keys (strings in 'YYYY-MM-DD' format) and sales numbers as values.Create a variable called
promo_start with the start date of the promotion as a string.Create a variable called
promo_end with the end date of the promotion as a string.Use
matplotlib to plot the sales data as a line chart.Highlight the promotional date range on the chart using
ax.axvspan().💡 Why This Matters
🌍 Real World
Highlighting date ranges on charts helps businesses see important periods like promotions, holidays, or events clearly in their data.
💼 Career
Data analysts and scientists often need to visualize time series data and emphasize specific periods to communicate insights effectively.
Progress0 / 4 steps