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
⏱ 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"])
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
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.
Customizing titles with Seaborn
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
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
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.
⭐ Seaborn graph gallery
If you're interested in a specific type of chart like boxplot or heatmap, I suggest to visit the dedicated section of the gallery. In case you're interested in what
seaborn can do, here is a glimpse of what's offered in the gallery 🧐.