0
0
Matplotlibdata~15 mins

Pyplot interface overview in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Pyplot Interface Overview
📖 Scenario: You are working as a data analyst and want to create a simple line chart to visualize sales data over a week. You will use the matplotlib.pyplot interface to plot the data.
🎯 Goal: Build a simple line plot using matplotlib.pyplot to show sales numbers for each day of the week.
📋 What You'll Learn
Create a list of sales numbers for 7 days
Create a list of day names for the x-axis
Use matplotlib.pyplot to plot the sales data
Add labels for x-axis and y-axis
Display the plot
💡 Why This Matters
🌍 Real World
Line charts are common in business to track sales, website visits, or any data changing over time.
💼 Career
Data analysts and scientists use matplotlib.pyplot to quickly visualize data and communicate insights.
Progress0 / 4 steps
1
Create sales data and days list
Create a list called sales with these exact values: [150, 200, 170, 220, 180, 190, 210]. Also create a list called days with these exact values: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].
Matplotlib
Need a hint?

Use square brackets to create lists. Put the exact numbers and day names as shown.

2
Import pyplot and set up plot
Import matplotlib.pyplot as plt. This will allow you to use plotting functions easily.
Matplotlib
Need a hint?

Use the syntax import matplotlib.pyplot as plt to import pyplot.

3
Plot sales data with labels
Use plt.plot(days, sales) to create a line plot. Then add x-axis label "Days" using plt.xlabel("Days") and y-axis label "Sales" using plt.ylabel("Sales").
Matplotlib
Need a hint?

Use plt.plot() to draw the line. Use plt.xlabel() and plt.ylabel() to add labels.

4
Display the plot
Use plt.show() to display the plot window with your line chart.
Matplotlib
Need a hint?

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