I’ve reviewed the boxplot documentation and the workaround for supplying precomputing statistics for boxplots (https://plot.ly/~chris/18051/#code). Yet I still cannot achieve the following. Does anyone know how to achieve this grouping and coloring of boxes on a single plot?

Thanks for the quick and helpful reply, Etienne! I was able to get closer to what I’m looking for, but ran into some troubles.

How can I get labels under each box, as opposed to labeling each “group?”

More importantly, how do I eliminate the huge spaces between groups? (See image. I’ve already reduced the boxgap and boxgroupgap to 0.1 each.) When I have 1 item per group, the bar width is excellent (it fills the whole space for that group. As soon as I add another item, all the boxes become really skinny with all this margin/padding.

As soon as I go up to 5 or 6 groups, I end up with super skinny boxplots that are hard to read. Here’s the best I’ve been able to come up with; notice that the bars are super skinny with too much space between them.

Thanks for the suggestion. This looks like it requires prior knowledge of how many items there are in each group. Sometimes I might have 1, 2, 3, 4 or perhaps 0 items. Is there a way to do this that wouldn’t require manually offsetting positions?

I had a similar problem. I was trying to subset the data and then plot each subset as a grouped boxplot.

The only solution I could get was to plot each set of data as a seperate plot. For some reason it leaves the space for all the diffrent groups on one plot. I had to create a new dataframe within each plot for the data specific to it.