This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Distribution of Violin Plot

Can someone explain why the violin plot on the right has more peaks than another? The distribution of data points is almost the same between the two sides but shapes are different. enter image description here

ggplot2 ggplot violin plot

1 answer

The violin plot is just a reversed and mirrored density plot. Both are based on a Kernell density estimate which require an important parameter called the bandwidth (h on the figure below). The higher the bandwidth, the smoother the curve (like for the violin plot on the left), while with lower bandwidth, individual data points have more impact.

bandwidth

Thank you! That is really helpful!

Log in to answer this question.