0
0
Matplotlibdata~30 mins

Spine charts concept in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Create a Spine Chart with Matplotlib
📖 Scenario: You work as a data analyst for a company that wants to visualize the sales performance of different products over several months. Your manager asks you to create a spine chart to compare the sales trends clearly.
🎯 Goal: Build a spine chart using matplotlib to show sales data for three products over four months. You will create the data, configure the plot, draw the spine chart, and display the result.
📋 What You'll Learn
Create a dictionary called sales_data with sales numbers for three products over four months.
Create a list called months with the names of the four months.
Use matplotlib to plot a spine chart comparing the sales trends.
Label the x-axis with the months and add a legend for the products.
Display the final spine chart.
💡 Why This Matters
🌍 Real World
Spine charts help compare multiple categories over time or other continuous variables, making trends easy to spot for business decisions.
💼 Career
Data analysts and scientists often create spine charts to visualize and communicate trends clearly to stakeholders.
Progress0 / 4 steps
1
Create the sales data dictionary
Create a dictionary called sales_data with these exact entries: 'Product A': [150, 200, 250, 300], 'Product B': [180, 210, 230, 280], and 'Product C': [100, 150, 200, 250].
Matplotlib
Need a hint?

Use curly braces to create a dictionary. Each product name is a key, and the sales numbers are lists as values.

2
Create the months list
Create a list called months with these exact strings: 'Jan', 'Feb', 'Mar', and 'Apr'.
Matplotlib
Need a hint?

Use square brackets to create a list with the exact month names as strings.

3
Plot the spine chart
Import matplotlib.pyplot as plt. Use a for loop with variables product and sales to iterate over sales_data.items(). Inside the loop, plot the sales data using plt.plot(months, sales, marker='o', label=product). Then add a legend with plt.legend().
Matplotlib
Need a hint?

Remember to import matplotlib.pyplot as plt first. Use a for loop to plot each product's sales with markers and labels.

4
Display the spine chart
Add plt.xlabel('Months') and plt.ylabel('Sales') to label the axes. Then use plt.title('Sales Trends Spine Chart') to add a title. Finally, display the plot with plt.show().
Matplotlib
Need a hint?

Use plt.xlabel, plt.ylabel, and plt.title to add labels and title. Use plt.show() to display the chart.