BMC SKILLZ HUB
206 subscribers
54 photos
4 videos
19 files
307 links
Download Telegram
Welcome to Day 9 of our Python for Data Analytics Series! Today, we’ll learn how to turn raw data into meaningful visual insights using Matplotlib and Seaborn. Data visualization helps you understand trends, patterns, and outliers, making complex data easier to comprehend.



🛠️ WHAT YOU’LL LEARN TODAY:
- Line plots and scatter plots using Matplotlib
- Bar plots and histograms using Seaborn
- Customizing charts with labels, titles, and colors



1. Line Plot with Matplotlib
A line plot is useful for visualizing trends over time or other continuous variables.


import matplotlib.pyplot as plt
import pandas as pd

# Sample Data
data = {'Year': [2017, 2018, 2019, 2020, 2021], 'Sales': [200, 300, 400, 500, 600]}
df = pd.DataFrame(data)

# Create Line Plot
plt.plot(df['Year'], df['Sales'])
plt.xlabel('Year')
plt.ylabel('Sales')
plt.title('Yearly Sales Trend')
plt.show()


🎯 *Why It Matters*: Line plots are great for showing how a variable changes over time, like sales growth or stock prices.



2. *Scatter Plot with Matplotlib*
Scatter plots are excellent for visualizing relationships between two continuous variables.



# Sample Data
age = [22, 25, 30, 35, 40]
income = [2000, 2500, 3000, 3500, 4000]

# Create Scatter Plot
plt.scatter(age, income)
plt.xlabel('Age')
plt.ylabel('Income')
plt.title('Age vs Income')
plt.show()


🎯 Why It Matters: Scatter plots help you see the relationship (or lack thereof) between two variables, such as age and income.



3. Bar Plot with Seaborn
Bar plots display data with rectangular bars, often used to compare different categories.


import seaborn as sns

# Sample Data
data = {'Product': ['A', 'B', 'C'], 'Sales': [100, 200, 300]}
df = pd.DataFrame(data)

# Create Bar Plot
sns.barplot(x='Product', y='Sales', data=df)
plt.title('Sales by Product')
plt.show()


🎯 Why It Matters: Bar plots make it easy to compare categorical data like product sales or survey responses.



4. Histogram with Seaborn
Histograms show the distribution of a dataset, often used to understand the frequency of certain values.


# Sample Data
ages = [22, 23, 24, 25, 26, 22, 24, 25, 26, 23]

# Create Histogram
sns.histplot(ages, bins=5)
plt.title('Age Distribution')
plt.show()


🎯 *Why It Matters*: Histograms are essential for understanding how data is distributed, which helps in identifying outliers and normality.



5. *Box Plot with Seaborn*
Box plots show the distribution of data based on quartiles and are useful for identifying outliers.


# Sample Data
data = {'Product': ['A', 'A', 'B', 'B'], 'Sales': [100, 150, 200, 250]}
df = pd.DataFrame(data)

# Create Box Plot
sns.boxplot(x='Product', y='Sales', data=df)
plt.title('Sales Distribution by Product')
plt.show()


🎯 Why It Matters: Box plots provide a summary of data spread and help detect outliers.



🎨 Customization in Matplotlib & Seaborn
You can customize your plots with labels, titles, colors, and more to make them more informative and visually appealing.


Customizing a Matplotlib Plot
plt.plot(df['Year'], df['Sales'], color='green', linestyle='--', marker='o')
plt.xlabel('Year', fontsize=12)
plt.ylabel('Sales', fontsize=12)
plt.title('Yearly Sales Trend', fontsize=15)
plt.show()
```

```

🎯 Why It Matters: Customizing your plots ensures clarity and makes your insights easier to communicate.



📝 Today’s Challenge:
1. Create a line plot using Matplotlib to visualize how a variable changes over time.
2. Use Seaborn to make a bar plot comparing different categories in a dataset.



In Day 10, we’ll wrap up the series by exploring Advanced Data Operations and Working with Large Datasets. Get ready to level up your data analytics skills! 💡📈

#PythonForDataAnalytics #Day9 #DataVisualization #Matplotlib #Seaborn #LearnPython #DataScienceJourney



Got any questions about data visualization? Feel free to ask below! 👇