Violin plot

入門

6.2.4

Violin plot

Last updated 2020-03-11 Read time 1 min

Violin plot is a box-and-whisker diagram with a density graph rotated 90 degrees on each side. Violin plot allows comparison of the distribution of values for several groups.

1
2
3
4
5
6
7
8
9
import matplotlib.pyplot as plt
import seaborn as sns

df = sns.load_dataset("iris")

sns.set(rc={"figure.figsize": (12, 8)})
sns.violinplot(x=df["species"], y=df["sepal_length"])

plt.show()

Violin plot

  • Box Plot — Compare median, quartiles, and outliers
  • Swarm Plot — Arrange individual data points without overlap
  • Ridgeline Plot — Compare distributions by category with overlapping ridges