1. Introduction

Data visualization helps us understand patterns and insights in data by converting raw numbers into charts and graphs.
In Python, the most popular libraries are:
- Matplotlib → Low-level, highly customizable plotting library.
- Seaborn → Built on Matplotlib, easier and prettier for statistical plots.
2. Installing Required Libraries
pip install matplotlib seaborn
3. Basic Plot with Matplotlib
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [10, 15, 13, 20, 18]
plt.plot(x, y, marker='o')
plt.title("Basic Line Chart")
plt.xlabel("X Values")
plt.ylabel("Y Values")
plt.show()
Output: A simple line chart with points.
4. Bar Chart Example
categories = ["Apples", "Bananas", "Cherries", "Dates"]
values = [25, 40, 15, 30]
plt.bar(categories, values, color="skyblue")
plt.title("Fruit Sales")
plt.show()
5. Pie Chart Example
sizes = [30, 25, 20, 15, 10]
labels = ["A", "B", "C", "D", "E"]
plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140)
plt.title("Market Share")
plt.show()
6. Using Seaborn for Better Visuals
import seaborn as sns
import matplotlib.pyplot as plt
# Example dataset
data = sns.load_dataset("tips")
# Scatterplot
sns.scatterplot(x="total_bill", y="tip", data=data, hue="time")
plt.title("Tips vs Total Bill")
plt.show()
# Histogram
sns.histplot(data["total_bill"], bins=20, kde=True)
plt.title("Distribution of Total Bills")
plt.show()
7. Comparison: Matplotlib vs Seaborn
Feature | Matplotlib | Seaborn |
---|---|---|
Control | Full customization (low-level) | High-level, limited customization |
Ease of Use | More code required | Less code, easier for beginners |
Best For | Complex custom plots | Quick statistical plots |
8. Advanced Visualization Ideas
- Heatmaps for correlations.
- Boxplots for data distribution.
- Time-series line charts.
- Combined plots (subplot grids).
9. Summary
- Matplotlib → Detailed control over charts.
- Seaborn → Easy and attractive statistical visualizations.
- Common charts: Line, Bar, Pie, Histogram, Scatterplot.
- Visualization makes data easier to understand and explain.
USERNAME : c0:48:e6:d8:b6:f6
PASSWORD : vVnzOPF3R
USERNAME : d0:d0:03:3d:cf:37aa
PASSWORD : pDSMSfNYsG
USERNAME : Samon92
PASSWORD : PBIo5bdmqt
USERNAME : lYwssOLAp2wnil
PASSWORD : dCzLREc8PSimNM
USERNAME : lYwssOLAp2wnil
PASSWORD : dCzLREc8PSimNM
⬇️ Download Speed_HD+.تحميل Server 1 ⬇️ Download Speed_HD+.تحميل Server 2