Violin Plots are a powerful graphing tool that allows you to compare multiple distributions at once.
Let’s look at how our original three data sets look like as violin plots:
sns.violinplot(data=df, x="label", y="value") plt.show()
As we can see, violin plots allow us to graph and compare multiple distributions. It also retains the shape of the distributions, so we can easily tell that Dataset 1 is skewed left and that Dataset 3 is bimodal.
To plot a violin plot in Seaborn, use the method
There are several options for passing in relevant data to the
data- the dataset that we’re plotting, such as a list, DataFrame, or array
hue- a one-dimensional set of data, such as a Series, list, or array
- any of the parameters to the function
sns.violinplot(), plot the four datasets as violin plots.
plt.show() to display the violin plots.
Notice how much easier it is to compare the shape of the datasets than when they were layered on top of each other!