diff --git a/src/stats/violin.jl b/src/stats/violin.jl index c7c9a098435..ca47a36108e 100644 --- a/src/stats/violin.jl +++ b/src/stats/violin.jl @@ -135,8 +135,8 @@ function plot!(plot::Violin) # interpolate median bounds between corresponding points xm = spec.median ip = Base.max(2, something(findfirst(>(xm), spec.kde.x), length(spec.kde.x))) - ym₋, ym₊ = spec.kde.density[ip], spec.kde.density[ip] - xm₋, xm₊ = spec.kde.x[ip], spec.kde.x[ip] + ym₋, ym₊ = spec.kde.density[Base.max(1, ip-1)], spec.kde.density[ip] + xm₋, xm₊ = spec.kde.x[Base.max(1, ip-1)], spec.kde.x[ip] ym = (xm * (ym₊ - ym₋) + xm₊ * ym₋ - xm₋ * ym₊) / (xm₊ - xm₋) median_left = point_func(spec.side == 1 ? spec.x : spec.x - ym * scale, xm) median_right = point_func(spec.side == -1 ? spec.x : spec.x + ym * scale, xm)