plotjuliaviolin-plotstatsplots.jl

Half violin plot in Julia


I would like to plot a half violin plot instead of a full violin plot. Here is some reproducible code which creates full violin plots:

using StatsPlots
StatsPlots.violin(repeat(["A", "B"],outer=100),randn(300))

Output:

enter image description here

As you can see it creates a full violin plot. In the docs I can't find anything about half violin plots. So I was wondering if anyone know if it is possible to creat half violin plots in Julia?


Solution

  • The optional argument side defaults to :both, so to have a half violin, use :left or :right like this:

    using StatsPlots
    StatsPlots.violin(repeat(["A", "B"],outer=100),randn(300), side = :left)
    

    Output:

    Half violin plot example

    Note that this behavior is not currently documented in the 'violin' method docs, but it is used in the examples.