Seaborn with example
📊 Seaborn in Python (Complete Guide with Examples)
Seaborn is a statistical data visualization library built on top of Matplotlib. It provides high-level interface for creating attractive and informative charts.
✅ 1. Installation
✅ 2. Importing Seaborn
✅ 3. Load Example Dataset
Seaborn comes with built-in datasets:
Output (example):
| total_bill | tip | sex | smoker | day | time | size |
|---|---|---|---|---|---|---|
| 16.99 | 1.01 | Female | No | Sun | Dinner | 2 |
| 10.34 | 1.66 | Male | No | Sun | Dinner | 3 |
✅ 4. Simple Scatter Plot
-
hue→ color by category -
data→ dataset -
x,y→ columns
✅ 5. Line Plot
✅ 6. Histogram / Distribution Plot
-
kde=True→ plots Kernel Density Estimate (smooth curve)
✅ 7. Box Plot
Shows distribution and outliers.
✅ 8. Bar Plot
Displays aggregate statistics.
✅ 9. Pair Plot
Visualizes relationships between all numerical columns.
✅ 10. Heatmap
Useful for correlation matrices.
🧠Summary Table
| Plot Type | Function | Notes |
|---|---|---|
| Scatter Plot | scatterplot() |
Relationship between two variables |
| Line Plot | lineplot() |
Trends over numeric x-axis |
| Histogram | histplot() |
Distribution of numeric data |
| Box Plot | boxplot() |
Distribution and outliers |
| Bar Plot | barplot() |
Mean values for categories |
| Pair Plot | pairplot() |
Scatter & distribution matrix |
| Heatmap | heatmap() |
Correlation or 2D data matrix |
