Change line width

Depending on visual preferences, you may want to accentuate the distribution contour. This can be performed by setting the value of the 'linewidth' parameter.

# libraries & dataset
import seaborn as sns
import matplotlib.pyplot as plt
  
sns.set_theme(style="darkgrid")
df = sns.load_dataset('iris')
 
# Change line width
sns.violinplot(x=df["species"], y=df["sepal_length"], linewidth=5)
plt.show()

Change the general width

In the case where you have multiple distributions to display on the same graph and you want to be sure that they do not overlap, you can also change the 'width' parameter.

# libraries & dataset
import seaborn as sns
import matplotlib.pyplot as plt
  
sns.set_theme(style="darkgrid")
df = sns.load_dataset('iris')

# Change width
sns.violinplot(x=df["species"], y=df["sepal_length"], width=0.3)
plt.show()

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