Through the following example, we expect to give an overview of the way clients tip throughout the week, considering smokers and non-smokers separately. The 'hue' parameter enables you to differentiate the data based on one column (boolean, categorical or ordinal data): here it is set to "smoker" which contains boolean data.

# libraries & dataset
import seaborn as sns
import matplotlib.pyplot as plt
# set a grey background (use sns.set_theme() if seaborn version 0.11.0 or above) 
df = sns.load_dataset('tips')
# Grouped violinplot
sns.violinplot(x="day", y="total_bill", hue="smoker", data=df, palette="Pastel1")

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