Search code examples
juliaplots.jl

BoxPlots with log scale in Julia


I am using Plots. When I use the log scale for the x-axis, the plot does not seem to be nice. The width of the box is not arranged.

Do you have any idea to overcome this?

boxplot([10 100 1000], [randn(10).+10 randn(10).+20 randn(10).+30], color="gray", legend=false, bar_width=50)

enter image description here

boxplot([10 100 1000], [randn(10).+10 randn(10).+20 randn(10).+30], color="gray", legend=false, bar_width=10, xscale=:log10)

enter image description here


Solution

  • using StatsPlots
    
    boxplot([10 100 1000], [randn(10).+10 randn(10).+20 randn(10).+30];
        color="gray", legend=false, bar_width=[2 20 200], xscale=:log10)
    

    Currently, the boxplot function seems to have been migrated to StatsPlots.jl. You can specify the width of individual bars by giving a series to bar_width. enter image description here