First, we need to import the following libraries:

import seaborn as sns
import matplotlib.pyplot as plt


We'll use the iris dataset that is available using the load_dataset() function from seaborn

df = sns.load_dataset("iris")

Flipped histogram

Flipping a histogram with seaborn is easy: you just have to specify that you want to display it on the y axis.


# Create the plot
sns.histplot(data=df, y="sepal_length")

Flipped histogram with density estimation

If you want to add the density estimation, you have to add kde=True in the histplot function


# Create the plot
sns.histplot(data=df, y="sepal_length", kde=True)

Going further

This post explains how to create a flipped histogram with seaborn.

You might be interested in creating histogram with multiple groups or controlling the bins.

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 🙏!