Description:
A Python program that uses both Seaborn and Matplotlib to create enhanced and customized data visualizations.
Code Explanation:
● sns.set(style="whitegrid")
sets a clean Seaborn style.
● sns.barplot()
is used to create a grouped bar chart using Seaborn.
● hue='Region'
splits bars by region for comparison.
● plt.title()
, plt.xlabel()
, and plt.ylabel()
are from Matplotlib to enhance the plot.
● plt.tight_layout()
improves spacing before displaying the plot.
Program:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# Sample Data
data = {
'Product': ['Laptop', 'Tablet', 'Smartphone', 'Headphones', 'Laptop', 'Tablet', 'Smartphone', 'Headphones'],
'Region': ['North', 'North', 'North', 'North', 'South', 'South', 'South', 'South'],
'Sales': [200, 150, 300, 100, 250, 180, 320, 120]
}
df = pd.DataFrame(data)
# Set seaborn theme
sns.set(style="whitegrid")
# Create a seaborn barplot
plt.figure(figsize=(6, 5))
sns.barplot(data=df, x='Product', y='Sales', hue='Region')
# Customize using matplotlib
plt.title("Product Sales by Region")
plt.xlabel("Product Category")
plt.ylabel("Units Sold")
plt.legend(title="Region")
plt.tight_layout()
# Show the plot
plt.show()
Output:
Trainings :
Data Science Training in Indore | Data Analytics Training in Indore | Python Training in Indore | Blockchain Training in Indore | React JS Training in Indore | Web Development Training in Indore | Full Stack Development Training in Indore |Free Courses and Resource :
Verbal Aptitude | Matplotlib Tutorials | Examples | Interview Questions | Pandas Tutorials | Projects | Interview Questions | OpenCV Tutorials | Projects | Interview Questions | ExpressJS Tutorials | Projects | Interview Questions | Dart | Python Data Structures and Algorithms | Rust Tutorials | Projects | Interview Questions | Aptitude Tests | HackerRank Python | Django | MongoDB Tutorials | Examples | Interview Questions | NumPy Practice Questions | Python Tutorials by CodersDaily | Golang Tutorials | Projects | Interview Questions | React.js Tutorials | Verbal Ability Tutorial | MS Sql Server Tutorials | Examples | Interview Questions | Power BI Tutorials | Projects | Interview Questions | Example Dashboards | Numpy Tutorials | Projects | Interview Questions | Django REST Framework Tutorial | HackerRank C++ Solutions | Tensor Flow | Pandas Practice Questions | Python Practice Questions | C++ Tutorials | Quantitative Ability Tutorial | Javascript | Node.js Tutorials | HackerRank SQL Solutions | HackerRank DSA Solutions | Verbal Aptitude 2 | HackerRank Java Solutions | HTML Tutorial | TCS NQT Mock Test Series | Reasoning Ability Tutorial | CodeChef Python Solutions | HackerRank C Program Solutions | Leetcode Python Solutions | SQL Practice Question | Matplotlib Practice Questions |Interview Questions :
Pandas Tutorials | Projects | Interview Questions | ExpressJS Tutorials | Projects | Interview Questions | Django | Python Tutorials by CodersDaily | Golang Tutorials | Projects | Interview Questions | Numpy Tutorials | Projects | Interview Questions | Django REST Framework Tutorial |Top Colleges in India :
Indian Institute of Technology Bombay | Jaypee University of Engineering and Technology - Guna |