Skip to main content
Seaborn is a Python visualization library built directly on top of Matplotlib, designed specifically for statistical graphics. Where Matplotlib gives you complete control at the cost of verbosity, Seaborn lets you produce elegant, informative charts in a single function call — and it integrates seamlessly with Pandas DataFrames. You pass your DataFrame and column names directly to Seaborn functions, and it handles the aggregation, styling, and statistical overlays automatically. This makes it the go-to library for exploratory data analysis in data science and machine learning workflows.

Installation and Import

Styling and Themes

One sns.set_theme() call controls the visual style of all subsequent plots.
Available styles: whitegrid, darkgrid, ticks, white, dark Available contexts (scale fonts and element sizes): paper, notebook, talk, poster

Analyzing Numerical Distributions

Distribution plots help you understand how a single continuous variable is spread — its range, center, skewness, and density.

Histograms with KDE (sns.histplot)

Combine a histogram with a Kernel Density Estimation (KDE) curve for a smooth probability overlay:

Joint Plots (sns.jointplot)

A joint plot shows the bivariate relationship between two variables (scatter or hex plot) alongside the univariate distribution of each variable on the margins:
kind options include "scatter", "hex", "kde", and "reg".

Pair Plots (sns.pairplot)

A pair plot creates a grid that compares every numerical column against every other — scatter plots off the diagonal, distributions on the diagonal. It is one of the fastest ways to get an overview of a new dataset.
Always start exploratory data analysis with sns.pairplot(). In a single call you’ll spot correlations, clusters, outliers, and skewed distributions that would take many individual plots to uncover.

Categorical Visualizations

Categorical plots compare a numerical variable across discrete groups.

Bar Plots (sns.barplot)

Seaborn’s bar plot automatically aggregates data (mean by default) and draws confidence interval error bars:

Count Plots (sns.countplot)

A count plot shows the frequency of each category — equivalent to a histogram for categorical data:

Box Plots vs. Violin Plots

Both charts compare distributions across categories, but they reveal different aspects of the data:

Relationship and Regression Plots

Scatter Plots (sns.scatterplot)

Map a third variable to point color (hue) and a fourth to point size (size) to pack more information into a single chart:

Regression Plots (sns.lmplot)

Draws a scatter plot overlaid with a fitted linear regression line and shaded confidence bands:
sns.lmplot always creates its own figure, so you cannot pass an ax parameter. Use sns.regplot if you need to embed a regression line inside an existing subplot grid.

Correlation Heatmaps

A heatmap visualizes the correlation matrix of a DataFrame — making it easy to spot which pairs of features are strongly or weakly related.
Correlation values range from -1 (perfect negative correlation) to +1 (perfect positive correlation). Values close to 0 indicate no linear relationship.
Correlation measures only linear relationships. A near-zero correlation doesn’t necessarily mean two variables are unrelated — they may have a non-linear relationship. Always visualize your data before drawing conclusions from correlation alone.

Seaborn Chart Quick Reference