0
0
Data Analysis Pythondata~30 mins

Line plots in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Line plots
📖 Scenario: You are a data analyst working with monthly sales data for a small store. You want to visualize how sales changed over the first six months of the year.
🎯 Goal: Create a line plot to show monthly sales trends from January to June.
📋 What You'll Learn
Create a dictionary with months as keys and sales numbers as values
Create a list of months in order
Use matplotlib to plot sales data as a line plot
Label the x-axis as 'Month' and y-axis as 'Sales'
Display the plot
💡 Why This Matters
🌍 Real World
Line plots are used to show trends over time, like sales, temperature, or stock prices.
💼 Career
Data analysts and scientists use line plots to communicate patterns and changes clearly to others.
Progress0 / 4 steps
1
Create the sales data dictionary
Create a dictionary called sales_data with these exact entries: 'Jan': 150, 'Feb': 200, 'Mar': 180, 'Apr': 220, 'May': 210, 'Jun': 230.
Data Analysis Python
Hint

Use curly braces {} to create a dictionary with month names as keys and sales numbers as values.

2
Create the list of months in order
Create a list called months with these exact values in order: 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'.
Data Analysis Python
Hint

Use square brackets [] to create a list of months in the correct order.

3
Plot the sales data as a line plot
Import matplotlib.pyplot as plt. Create a list called sales that contains the sales numbers from sales_data in the order of months. Use plt.plot(months, sales) to create a line plot.
Data Analysis Python
Hint

Use a list comprehension to get sales numbers in order. Then use plt.plot() to draw the line plot.

4
Add labels and display the plot
Use plt.xlabel('Month') and plt.ylabel('Sales') to label the axes. Then use plt.show() to display the plot.
Data Analysis Python
Hint

Use plt.xlabel() and plt.ylabel() to add axis labels. Then call plt.show() to display the plot window.