Violin plot

Hi there,

It seems like violin plots truncate the support of the data. My understanding is that violin plots are kernel density estimates of the data but I’m struggling to find more information about the actual details.

Thanks in advance!
Miguel.

Looking at the code, I think that by default the violin plots in StatsPlots.jl don’t go beyond the minimum and maximum values in the dataset. And that to change the default violin() plot we should set the keyword argument trim=false.

Thanks for the answer! I will look closer into the code. The problem in my case is that its truncating the lower support above the minimum. It might be an issue with outliers.

In a quick test comparison with boxplot I could not see any problem as the (default) violin plot extended up to the outliers.

Yep, it might only be failing in my case where the data is kind of not too well behaved since I have some very large outliers. I can not provide a MWE bu just to illustrate:

df |>
    x -> @df x boxplot(:time_period, :max_down_speed, legend = false, title = "CAF II model", showaxis = :y, outliers = false)
    df |>
    x -> @df x violin!(:time_period, :max_down_speed)

Gives: