A violin plot is a graphical representation employed to depict the distribution of a dataset, showcasing important statistics like the median, quartiles, and possible outliers. It offers a succinct summary of the central tendency and dispersion of the data.

Creating violin plots with Seaborn allows us to easily visualize the distribution. In this post, we will explore how to use Seaborn to create a horizontal violin plot.


First, you need to install the following librairies:

import seaborn as sns
import matplotlib.pyplot as plt


The dataset we will use is the iris dataset, which we can easily download with seaborn:

df = sns.load_dataset('iris')

Violin plot

Fortunately, it's a very light syntax to create a violin plot with seaborn thanks to the violinplot() function:

# Just switch x and y
sns.violinplot(x=df["species"], y=df["sepal_length"])

Flipped violin plot

Flipping this graph is actually quite simple, as all you have to do is exchange the arguments x and y.

# Just switch x and y
sns.violinplot(y=df["species"], x=df["sepal_length"])

Going further

This post explains how to create a horizontal violin plot with seaborn.

For more examples of how to create or customize your violin plots, check the violin plot section. You may also be interested in how to customize a violin plot.

Contact & Edit

👋 This document is a work by Yan Holtz. You can contribute on github, send me a feedback on twitter or subscribe to the newsletter to know when new examples are published! 🔥

This page is just a jupyter notebook, you can edit it here. Please help me making this website better 🙏!