Title and axis labels
📖 Scenario: You are analyzing sales data for a small store. You want to create a simple line chart to show how sales changed over a week.
🎯 Goal: Create a line chart using matplotlib with a title and labels for the x-axis and y-axis to clearly explain the chart.
📋 What You'll Learn
Create a list called
days with the days of the week from Monday to Sunday.Create a list called
sales with the sales numbers for each day: 150, 200, 170, 220, 180, 190, 210.Use
matplotlib.pyplot to plot the sales data as a line chart.Add a chart title using
plt.title() with the text 'Weekly Sales'.Add an x-axis label using
plt.xlabel() with the text 'Day of the Week'.Add a y-axis label using
plt.ylabel() with the text 'Sales (units)'.Display the chart using
plt.show().💡 Why This Matters
🌍 Real World
Adding titles and axis labels helps anyone looking at your charts understand what the data means quickly.
💼 Career
Data scientists and analysts always label their charts clearly to communicate insights effectively to others.
Progress0 / 4 steps