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"])
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
🧐 Mainseaborn
functions
Seaborn
is a wrapper of matplotlib, meaning that when you call a function in seaborn, it calls one or multiple matplotlib functions under the hood.
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.
relplot()
- High-level interface for creating scatter and line plots.scatterplot()
- For creating scatter plots.lineplot()
- For creating line plots.displot()
- For creating distribution plots, including histograms and KDE.histplot()
- For creating histograms.boxplot()
- For creating box plots.violinplot()
- For creating violin plots.heatmap()
- For creating heatmaps.pairplot()
- For creating a grid of scatter plots for pairwise relationships.catplot()
- High-level interface for creating various categorical plots.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 comes with a few built-in themes. Those themes are available through the set_style()
function. Here is an overview of what is offered.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4