#36 Add jitter over boxplot | seaborn

 

 

 

 

Boxplot is an amazing way to study distributions. However, note that different type of distribution can be hidden under the same box.

Thus, it is highly advised to display every observations over your boxplot, to be sure not to miss an interesting pattern. Note that violin plots can be an interesting alternative if you have many many observations.

 

 

 

 


# library & dataset
import seaborn as sns
df = sns.load_dataset('iris')

# Usual boxplot
ax = sns.boxplot(x='species', y='sepal_length', data=df)

# Add jitter with the swarmplot function.
ax = sns.swarmplot(x='species', y='sepal_length', data=df, color="grey")

Leave a Reply

Your email address will not be published.