Grouped boxplot - https://github.com/JuliaPlots/StatsPlots.jl/pull/192

I have a 3D array (24×3×3 Array{Float64,3}) as follows:
x=rand(24,2,3)

How can I plot a grouped boxplot for x as shown in the following figure?
46959378-e3652400-d069-11e8-8157-8c0bd1f0c255

There’s a groupedboxplot recipe with the same syntax as grouped histograms https://github.com/JuliaPlots/StatsPlots.jl#grouped-histograms

Hi mkborregaard,

Thank you for your reply.

The groupedboxplot was not be able to represent the 3D array.
According to the above figure, the sizes of x, y and z should be 2, 24 and 3, respectively. Therefore, let’s consider the random 3D array structure as rand(2,24,3). Here, using the groupedboxplot(rand(2,24,3)) just plotting x and y but neglecting z. (sorry I could not upload the figure as I am a new user. Can you please try it and see the results of groupedboxplot(rand(2,24,3))?)

Thank you again for your cooperation, and I look forward to hearing from you on this matter.

I tried the following code and it sounds that it does not result any grouping.

using Plots
using StatsPlots

x = rand(2,24,3)
x1 = x[:,:,1]

groupedboxplot(x, bar_position = :dodge, bar_width=0.7)
groupedboxplot(x1, bar_position = :dodge, bar_width=0.7)

Any suggestion to end up with a grouped boxplot?

You can’t use 3-d arrays - the easiest is to put the dataset in long format (x, y, group)

I still confused. Could you please help to provide a piece of code for that?

Perhaps kind of late but I came in this post when looking for groupedboxplot. Since other people can end here too, the answer is:

groupedboxplot(rand(["a","b"], 30), rand(30), group=rand(["C","D"], 30), legend=:bottom,  bar_position = :dodge, bar_width=0.7)

2 Likes

still useful!

1 Like