Seaborn with example

📊 Seaborn in Python

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

pip install seaborn

 2. Importing Seaborn



3. Load Example Dataset

Seaborn comes with built-in datasets:


Output (example):

total_billtipsexsmokerdaytimesize
16.991.01FemaleNoSunDinner2
10.341.66MaleNoSunDinner3

 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 TypeFunctionNotes
Scatter Plotscatterplot()Relationship between two variables
Line Plotlineplot()Trends over numeric x-axis
Histogramhistplot()Distribution of numeric data
Box Plotboxplot()Distribution and outliers
Bar Plotbarplot()Mean values for categories
Pair Plotpairplot()Scatter & distribution matrix
Heatmapheatmap()Correlation or 2D data matrix

🎯 Practical Example


 

You may also like...