0
0
Matplotlibdata~30 mins

Bar chart color customization in Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Bar chart color customization
📖 Scenario: You work in a small bakery and want to show how many cakes you sold each day last week. You want to make a bar chart to show this clearly to your team.
🎯 Goal: Create a bar chart using matplotlib that shows the number of cakes sold each day. Customize the colors of the bars so that each day has a different color.
📋 What You'll Learn
Create a dictionary called sales with days of the week as keys and number of cakes sold as values.
Create a list called colors with a different color for each day.
Use matplotlib.pyplot.bar() to make a bar chart with the sales data and the colors list.
Display the bar chart with plt.show().
💡 Why This Matters
🌍 Real World
Businesses often use bar charts to show sales or performance data clearly to teams and customers.
💼 Career
Data analysts and scientists use color customization in charts to make reports easier to understand and visually appealing.
Progress0 / 4 steps
1
Create the sales data dictionary
Create a dictionary called sales with these exact entries: 'Monday': 20, 'Tuesday': 35, 'Wednesday': 30, 'Thursday': 25, 'Friday': 40, 'Saturday': 50, 'Sunday': 45.
Matplotlib
Need a hint?

Use curly braces {} to create the dictionary with the exact days and numbers.

2
Create a list of colors for the bars
Create a list called colors with these exact color names in order: 'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'.
Matplotlib
Need a hint?

Make sure the list has exactly these colors in this order.

3
Create the bar chart with colors
Import matplotlib.pyplot as plt. Use plt.bar() with the days from sales.keys(), the cake counts from sales.values(), and the colors list to set the bar colors.
Matplotlib
Need a hint?

Use plt.bar() with the color parameter set to the colors list.

4
Display the bar chart
Use plt.show() to display the bar chart you created.
Matplotlib
Need a hint?

Call plt.show() to display the chart window.