Boxplot with multiple categories in Dash

Hi,

I have a question regarding box-plots have multiple categories. I have seen documentation using Plotly R doing that Axes | R | Plotly but I’m not sure if there is a way to replicate it using Dash.

Appreciate your help in advance.

Thanks,
Raghu

For now, you’d have to do some tricks with annotations or just plot multiple figures, each figure having its own category.

We’re looking to provide a first class solution to this in the graphing library with this issue: https://github.com/plotly/plotly.js/issues/2799

Thanks @chriddyp For now I’m using subplots and appending traces for each category.

A lot of work has obviously gone into implementing multi-category axes. This is an old thread, but the OP did reference boxplots. Converting the example in the docs (which uses bar plots) to boxplots doesn’t seem to match the intended outcome. Have I made a mistake with the following:

var trace1 = {
  x: [
    ['SF Zoo','SF Zoo','SF Zoo'],
    ['giraffes', 'orangutans', 'monkeys']
  ],
  y: [[20, 14, 23], [21, 13, 15], [20, 14, 23]],
  name: 'SF Zoo',
  type: 'box'
};

var trace2 = {
  x: [
    ['LA Zoo','LA Zoo','LA Zoo'],
    ['giraffes', 'orangutans', 'monkeys']
  ],
  y: [[25, 1, 24], [22, 13, 19], [20, 14, 23]],
  name: 'LA Zoo',
  type: 'box'
};

var data = [trace1, trace2];
var layout = {
  showlegend: false,
  xaxis: {
    tickson: "boundaries",
    ticklen: 15,
    showdividers: true,
    dividercolor: 'grey',
    dividerwidth: 2
  }
};

Plotly.newPlot('myDiv', data, layout);