Side by side violin plots with VegaLite.jl

A promising alternative is using split violins in CairoMakie

using CairoMakie

xs1 = rand(["a", "b", "c"], 1000)
ys1 = randn(1000)
dodge1 = rand(1:2, 1000)

xs2 = rand(["a", "b", "c"], 1000)
ys2 = randn(1000)
dodge2 = rand(1:2, 1000)

fig = Figure()
ax = Axis(fig[1, 1])
violin!(ax, xs1, ys1, dodge = dodge1, side = :left, color = "orange")
violin!(ax, xs2, ys2, dodge = dodge2, side = :right, color = "teal")
fig

which produces


Looks nice, I think.

However, with my actual data, it looks like this


Seems off to me. Because of differences in variance, there are large differences in the total area of different halves of the same violin, despite having the same amount of data. Would be nice to have the area preserved i.e. the more spread out treatments are also shallower.

1 Like