Asymmetric violin plot (different right/left series)

Hello, I am trying to obtain a violin plot with different series on the right and on the left.

I have tried this code plying from the example in the doc, but I am unable to specify that one series should be on the left and the other one on the right:

singers = dataset("lattice","singer")
singers[:chorus] = "Scala"
singers2 = deepcopy(singers)
singers2[:Height] = singers2[:Height]+5
singers2[:chorus] = "Moscow"
singersTot = vcat(singers,singers2)
myPlot = violin(singersTot,:VoicePart,:Height, group=:chorus, marker=(0.2,:blue,stroke(0)))

ok, it seems it was not possible… I worked on the StatsPlots package and issued a pull request to allow an additional :side parameter:

using DataFrames, Plots, StatPlots, RDatasets
singers = dataset("lattice","singer")
singers[:chorus] = "Scala"
singers2 = deepcopy(singers)
singers2[:Height] = singers2[:Height]+5
singers2[:chorus] = "Moscow"
singersTot = vcat(singers,singers2)
myPlot = violin(singers,:VoicePart,:Height, side=:right, marker=(0.2,:blue,stroke(0)), label="Scala")
violin!(singers2,:VoicePart,:Height, side=:left, marker=(0.2,:red,stroke(0)), label="Moscow")

5 Likes

Thanks for the nice work!