Bird
0
0
Raspberry Piprogramming~30 mins

Matplotlib for data visualization in Raspberry Pi - Mini Project: Build & Apply

Choose your learning style9 modes available
Matplotlib for data visualization
📖 Scenario: You work at a small local store that tracks daily sales. You want to show the sales data visually to understand trends better.
🎯 Goal: Create a simple bar chart using Matplotlib to display daily sales amounts.
📋 What You'll Learn
Create a dictionary with sales data for 5 days
Set a color variable for the bars
Use Matplotlib to create a bar chart from the sales data
Display the bar chart
💡 Why This Matters
🌍 Real World
Visualizing sales data helps store owners quickly see which days have higher sales and make better business decisions.
💼 Career
Data visualization is a key skill for data analysts and scientists to communicate insights clearly to others.
Progress0 / 4 steps
1
Create sales data dictionary
Create a dictionary called daily_sales with these exact entries: 'Monday': 150, 'Tuesday': 200, 'Wednesday': 170, 'Thursday': 220, 'Friday': 190.
Raspberry Pi
Hint

Use curly braces to create a dictionary with days as keys and sales as values.

2
Set bar color
Create a variable called bar_color and set it to the string 'skyblue' to use as the color for the bars in the chart.
Raspberry Pi
Hint

Assign the string 'skyblue' to the variable bar_color.

3
Create bar chart with Matplotlib
Import matplotlib.pyplot as plt. Use plt.bar() with daily_sales.keys() as the x-axis and daily_sales.values() as the heights. Set the color parameter to bar_color.
Raspberry Pi
Hint

Use plt.bar(x, height, color=bar_color) where x is the days and height is the sales values.

4
Display the bar chart
Use plt.show() to display the bar chart you created.
Raspberry Pi
Hint

Call plt.show() to open a window with the bar chart.