1. Introduction and Styling
Importing Seaborn
By convention, Seaborn is imported assns:
Themes and Palettes
Seaborn allows you to change the global appearance of plots with one command.- Styles:
whitegrid,darkgrid,ticks,white,dark. - Contexts:
paper,notebook,talk,poster(scales fonts and sizes).
2. Analyzing Numerical Distributions
Distribution plots help you understand the range, skewness, and density of numerical features.Histograms and KDE (sns.histplot)
You can plot histograms combined with Kernel Density Estimation (KDE) to see a smoothed probability curve over the bars.
Joint Plots (sns.jointplot)
Joint plots draw a bivariate relationship (like a scatter plot) along with univariate distributions (histograms) on the margins.
Pair Plots (sns.pairplot)
Pair plots create a grid of scatter plots and histograms comparing every numerical column in a DataFrame against every other numerical column. This is one of the most common first steps in Machine Learning data exploration.
3. Categorical Visualizations
Categorical plots are used to inspect statistical aggregates across distinct categories.Bar Plots (sns.barplot)
Seaborn’s barplot automatically aggregates data (calculating the mean by default) and draws error bars representing confidence intervals.
Count Plots (sns.countplot)
A count plot counts the number of records (rows) in each category (similar to a bar plot of frequencies).
Violin Plots vs. Box Plots
sns.boxplot: Shows the quartiles and outliers.sns.violinplot: Combines a box plot with a KDE density estimation, showing the shape of the data distribution.
4. Relationship and Regressions
Scatter Plots and Line Plots
sns.scatterplot: Plots data points with color (hue) and size mapping.sns.lineplot: Plots trends, grouping, and error bands.
Regression Plots (sns.lmplot)
Draws a scatter plot along with a fitted linear regression line and confidence bands.
5. Matrix Plots (Correlation Heatmaps)
Heatmaps are highly useful for visualizing correlation tables between numerical variables.Heatmaps (sns.heatmap)
To plot correlation matrices:
- Select only the numerical columns from the DataFrame.
- Compute the Pearson correlation using
.corr(). - Draw the heatmap with values printed inside the boxes.
Practice and Next Steps
Before moving to the next section, make sure to practice your Seaborn skills using the interactive notebook:Seaborn Practice Exercise
Practice your skills using the interactive notebook.💻 VS Code | 🚀 Colab | 📥 Download
Next Step: Data Visualization Guide
See a comprehensive guide comparing univariate, bivariate, and multivariate analysis on student data.