0
0
Matplotlibdata~30 mins

Customizing Seaborn plots with Matplotlib - Mini Project: Build & Apply

Choose your learning style9 modes available
Customizing Seaborn plots with Matplotlib
📖 Scenario: You are analyzing sales data for a small store. You want to visualize the monthly sales using a bar plot. You will use Seaborn to create the plot and then customize it using Matplotlib to make it clearer and more attractive.
🎯 Goal: Create a Seaborn bar plot of monthly sales and customize it using Matplotlib by adding a title, axis labels, and changing the color of the bars.
📋 What You'll Learn
Create a dictionary called sales_data with months as keys and sales numbers as values
Create a list called highlight_months containing months to highlight
Use Seaborn to create a bar plot of the sales data
Use Matplotlib to add a title and axis labels
Change the color of bars for the months in highlight_months to a different color
💡 Why This Matters
🌍 Real World
Visualizing sales data helps businesses understand trends and make decisions. Customizing plots makes the information clearer and more appealing to stakeholders.
💼 Career
Data analysts and scientists often use Seaborn and Matplotlib to create and customize visualizations for reports and presentations.
Progress0 / 4 steps
1
DATA SETUP: Create the sales data dictionary
Create a dictionary called sales_data with these exact entries: 'January': 150, 'February': 200, 'March': 170, 'April': 220, 'May': 190.
Matplotlib
Need a hint?

Use curly braces {} to create a dictionary with the given month names as keys and sales numbers as values.

2
CONFIGURATION: Define months to highlight
Create a list called highlight_months containing the months 'February' and 'April' to highlight in the plot.
Matplotlib
Need a hint?

Use square brackets [] to create a list with the two month names as strings.

3
CORE LOGIC: Create and customize the Seaborn bar plot
Import seaborn as sns and matplotlib.pyplot as plt. Create a bar plot using sns.barplot with months on the x-axis and sales on the y-axis from sales_data. Use a list comprehension to set the color of bars to 'orange' if the month is in highlight_months, otherwise 'skyblue'. Then add a title 'Monthly Sales' and axis labels 'Month' and 'Sales' using Matplotlib.
Matplotlib
Need a hint?

Use list() to get keys and values from the dictionary. Use a list comprehension to create the colors list. Pass palette=colors to sns.barplot. Use plt.title, plt.xlabel, and plt.ylabel to add text.

4
OUTPUT: Display the customized plot
Use plt.show() to display the plot with the custom colors, title, and axis labels.
Matplotlib
Need a hint?

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