Skip to content

Introduction to Seaborn

What is Seaborn?

Seaborn is a Python visualization library built on top of Matplotlib.

It provides:

  • Better default styles
  • High-level charts for statistics
  • Easy integration with Pandas DataFrames

Seaborn is especially useful in EDA because you can quickly create informative plots with fewer lines of code.

Install and import

Import seaborn
import seaborn as sns
import matplotlib.pyplot as plt
 
print(sns.__version__)
Import seaborn
import seaborn as sns
import matplotlib.pyplot as plt
 
print(sns.__version__)

Seaborn’s core idea

Most Seaborn functions work well with tidy (long) data:

  • One row per observation
  • One column per variable

That’s why Pandas reshaping (meltmelt, pivot_tablepivot_table) is useful.

A first Seaborn plot

First Seaborn plot
import seaborn as sns
import matplotlib.pyplot as plt
 
x = [1, 2, 3, 4, 5]
y = [1, 4, 9, 16, 25]
 
sns.lineplot(x=x, y=y)
plt.title("Seaborn line plot")
plt.tight_layout()
plt.show()
First Seaborn plot
import seaborn as sns
import matplotlib.pyplot as plt
 
x = [1, 2, 3, 4, 5]
y = [1, 4, 9, 16, 25]
 
sns.lineplot(x=x, y=y)
plt.title("Seaborn line plot")
plt.tight_layout()
plt.show()

Why analysts like Seaborn

  • Built-in confidence intervals and aggregations in some plots
  • Simple API for categorical comparisons
  • Great for quickly exploring distributions and relationships

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did