0
0
Matplotlibdata~15 mins

Basic plt.plot usage in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Basic plt.plot usage
📖 Scenario: You are a data analyst who wants to visualize the sales trend of a small shop over a week. You have the sales numbers for each day and want to create a simple line chart to see how sales changed.
🎯 Goal: Build a simple line plot using matplotlib.pyplot.plot to show sales over days.
📋 What You'll Learn
Create a list called days with values: [1, 2, 3, 4, 5, 6, 7]
Create a list called sales with values: [150, 200, 170, 220, 180, 210, 230]
Use plt.plot(days, sales) to create the line plot
Use plt.show() to display the plot
💡 Why This Matters
🌍 Real World
Line plots are used to visualize trends over time, like sales, temperature, or stock prices.
💼 Career
Data analysts and scientists use matplotlib to create charts that help explain data insights clearly.
Progress0 / 4 steps
1
Create the sales data lists
Create a list called days with values [1, 2, 3, 4, 5, 6, 7] and a list called sales with values [150, 200, 170, 220, 180, 210, 230].
Matplotlib
Need a hint?

Use square brackets to create lists with the exact numbers given.

2
Import matplotlib and prepare to plot
Import matplotlib.pyplot as plt to prepare for plotting.
Matplotlib
Need a hint?

Use import matplotlib.pyplot as plt to import the plotting library.

3
Create the line plot
Use plt.plot(days, sales) to create a line plot showing sales over days.
Matplotlib
Need a hint?

Call plt.plot with days as x-values and sales as y-values.

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

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