Get Started →
Distribution CategoricalNumerical

Violin Plot

ggplot2: geom_violin() · Package: ggplot2 · Variables: 1 numerical + 0-1 categorical

WHAT IS A VIOLIN PLOT?

A violin plot combines a box plot with a mirrored kernel density curve, revealing the full shape of the distribution — not just its summary statistics. It answers "what does the distribution actually look like?" and is especially valuable for detecting bimodal or multimodal distributions that box plots would hide. Common practice is to overlay a slim box plot inside the violin for the five-number summary. In ggplot2, use geom_violin() optionally combined with geom_boxplot(width = 0.1).

BEST FOR

  • · When distribution shape matters
  • · Detecting bimodality
  • · Richer alternative to box plot

AVOID WHEN

  • · Very small samples
  • · Non-technical audience
  • · Too many groups (10+)

R + GGPLOT2 CODE EXAMPLE

ggplot2
ggplot(mtcars, aes(x = factor(cyl), y = mpg)) +
  geom_violin(fill = "#ff6a00", alpha = 0.7) +
  geom_boxplot(width = 0.1) +
  labs(title = "MPG Distribution by Cylinders", x = "Cylinders", y = "MPG")

Run this code now

Paste the code above into RChat and see the violin plot rendered instantly in your browser.

Try RChat Free →

SIMILAR CHART TYPES

ALTERNATIVES FOR YOUR DATA TYPE