Seaborn


Seaborn is a python graphic library built on top of matplotlib. It allows to make your charts prettier with less code. This page provides general seaborn tips. Visit individual chart sections if you need a specific type of plot. Note that most of the matplotlib customization options also work for seaborn.

⏱ Quick start

seaborn offers some specific functions for almost every kind of charts. For instance, regplot() can be used to build a scatterplot.

Note that no additional code is needed to get the nice grey background with grid and some good defaults for the dots 😍. That's 4 lines of code for a pretty decent chart 🔥!

# library & dataset
import seaborn as sns
df = sns.load_dataset('iris')

# use the function regplot to make a scatterplot
sns.regplot(x=df["sepal_length"], y=df["sepal_width"])

Matplotlib logoBasic vocabulary

Since seaborn is built on top of matplotlib, most of its concepts and vocabulary are still correct. The figure below describes the anatomy of a matplotlib charts. It names all the main components, names that you need to know to understand the documentation properly.

⚠️ Disclaimer: this figure comes from the very complete matplotlib documentation. Have a look at it for a thorough explanation on how this library works.

Anatomy of a matplotlib chart: all the basic vocabulary you need to know to understand the documentation properly

🧐 Main seaborn functions

Here is an overview of the most common seaborn functions. It provides a glimpse of they're made for, what are their parameters and links to their official doc.

Todo 😞

Seaborn logoCustomizing titles with Seaborn

Since Seaborn is built on top of Matplotlib, title customization works pretty much the same. A seaborn chart (like the one you get with sns.boxplot()) actually returns a matplotlib axes instance.

This means that you will not be able to use the usual pyplot method plt.title(), but will have to use the corresponding argument for an axes which is ax.set_title(). This is described more in depth in this dedicated post:



Once you've understood how to add a title, customizing it should work the same as for matplotlib:

Seaborn logoCustomizing axis

The exact same concept than explained for titles above applies for axes. So please read the following blogpost about axis customization with matplotlib and apply it to your seaborn chart.

🌈 Seaborn built-in themes

Seaborn comes with a few built-in themes. Those themes are available through the set_style() function. Here is an overview of what is offered.

Todo 😞

Contact

👋 This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message onTwitter, or send an email pasting yan.holtz.data with gmail.com.

Violin

Density

Histogram

Boxplot

Ridgeline

Scatterplot

Heatmap

Correlogram

Bubble

Connected Scatter

2D Density

Barplot

Spider / Radar

Wordcloud

Parallel

Lollipop

Circular Barplot

Treemap

Venn Diagram

Donut

Pie Chart

Dendrogram

Circular Packing

Line chart

Area chart

Stacked Area

Streamgraph

Map

Choropleth

Hexbin

Cartogram

Connection

Bubble

Chord Diagram

Network

Sankey

Arc Diagram

Edge Bundling

Colors

Interactivity

Animation with python

Animation

Cheat sheets

Caveats

3D