Labels, titles, and legends
📖 Scenario: You are analyzing sales data for a small store. You want to create a simple bar chart to show the sales of different products. To make the chart clear, you will add labels to the axes, a title, and a legend.
🎯 Goal: Create a bar chart using Python's matplotlib library that shows product sales. Add an x-axis label, a y-axis label, a chart title, and a legend to explain the colors.
📋 What You'll Learn
Create a dictionary called
sales with product names as keys and sales numbers as values.Create a variable called
colors that assigns a color to each product.Use matplotlib to plot a bar chart with the sales data.
Add an x-axis label called
Product.Add a y-axis label called
Sales.Add a chart title called
Sales by Product.Add a legend that shows which color belongs to which product.
💡 Why This Matters
🌍 Real World
Adding labels, titles, and legends to charts helps people understand data clearly. This is important when sharing reports or presentations.
💼 Career
Data scientists and analysts often create charts to explain their findings. Knowing how to label charts properly is a key skill for clear communication.
Progress0 / 4 steps