0
0
Matplotlibdata~15 mins

Label, title, and axis names in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Label, title, and axis names
📖 Scenario: You are analyzing monthly sales data for a small store. You want to create a simple line chart to show how sales changed over the first six months of the year.
🎯 Goal: Create a line chart using matplotlib with proper labels for the x-axis and y-axis, and add a title to the chart.
📋 What You'll Learn
Create a list called months with the values: 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'
Create a list called sales with the values: 250, 300, 280, 350, 400, 420
Use plt.plot() to create a line chart with months on the x-axis and sales on the y-axis
Add the x-axis label 'Month' using plt.xlabel()
Add the y-axis label 'Sales' using plt.ylabel()
Add the chart title 'Monthly Sales Data' using plt.title()
Display the chart using plt.show()
💡 Why This Matters
🌍 Real World
Labeling charts clearly helps people understand data trends quickly, such as sales over months or temperatures over days.
💼 Career
Data scientists and analysts often create charts with clear labels and titles to communicate insights effectively to teams and clients.
Progress0 / 4 steps
1
Create the data lists
Create a list called months with these exact values: 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'. Also create a list called sales with these exact values: 250, 300, 280, 350, 400, 420.
Matplotlib
Need a hint?

Use square brackets [] to create lists. Separate items with commas.

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

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

3
Create the line chart with labels and title
Use plt.plot() with months and sales to create the line chart. Then add the x-axis label 'Month' with plt.xlabel(), the y-axis label 'Sales' with plt.ylabel(), and the chart title 'Monthly Sales Data' with plt.title().
Matplotlib
Need a hint?

Use plt.plot(x, y) to create the line chart. Use plt.xlabel(), plt.ylabel(), and plt.title() to add labels and title.

4
Display the chart
Use plt.show() to display the chart with the labels and title.
Matplotlib
Need a hint?

Use plt.show() to open the window with the chart.