tezvyn:

Violin Plots: Box Plots with a Sense of Shape

AI-drafted, machine-checkedSource: Wikipedia: Violin plotintermediate
Violin Plots: Box Plots with a Sense of Shape

A violin plot is a box plot that also shows the data's shape. It reveals multi-modal distributions or skews that a simple box plot would hide. Use it to compare distributions across categories, like server response times.

WHY IT EXISTS: Standard box plots are great for summarizing data with medians and quartiles, but they hide the shape of the distribution. You can't tell if your data has one peak (unimodal), two peaks (bimodal), or is uniformly distributed. Violin plots were invented to show the summary and the full distribution in one graphic.

THE MENTAL MODEL: Think of a violin plot as a box plot wearing its distribution as a coat. The box plot provides the statistical summary (median, interquartile range), while the 'violin' shape around it is a density plot. This shape shows you exactly where your data points are clustered, giving a much richer view than a simple box.

HOW IT WORKS: A violin plot combines two plots into one. First, a kernel density estimate (KDE) is generated from the data. A KDE is like a smoothed-out histogram that shows the probability density of the data at different values. This density curve is then plotted vertically. To create the 'violin' shape, this same curve is mirrored on the other side of a central axis. Often, a traditional box plot is overlaid in the middle of this shape to provide explicit quartile and median markers.

WHEN TO USE IT: Use violin plots when you need to compare the distribution of a continuous variable across multiple groups or categories. They are especially powerful when you suspect the distributions might be complex, such as bimodal or heavily skewed. For example, comparing latency distributions for different microservices could reveal that one service has two distinct performance modes.

WHEN NOT TO USE IT: Violin plots can be misleading for small datasets, as the kernel density estimation might create a smooth shape that doesn't accurately represent the few data points available. For small N, a strip plot or a simple box plot is often more honest. They can also become visually cluttered if you try to compare too many categories at once.

ONE CANONICAL EXAMPLE: A data scientist wants to compare customer satisfaction scores (from 1-100) across three different product versions: A, B, and C. A box plot might show they all have a median score of 85. However, a violin plot could reveal that Version A has a tight distribution around 85, Version B has a bimodal distribution with peaks at 70 and 95 (a love-it-or-hate-it product), and Version C has a long tail of low scores, indicating a significant group of unhappy users.

Read the original → en.wikipedia.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.