💸 Reduce costs by consolidating proprietary analytics & reporting software to open-source & Dash.
Challenge us to replace your analytics with Dash and reduce costs.

Multiple y-values (list) for 1 x-value

hey all,

is there a way to plot - in the same trace - multiple y-values for a single x-value? A pseudo-code example would be:

var layout = {
      autosize: true,
      height: 480,
      width: 1000
  };
  var trace1 = {
    name: 'trace1',
    x: [1, 2, 3, 4],
    y: [[1,3,5], [1,3,5], [1,3,5], [1,3,5]],
    fill: 'tonexty',
    type: 'scatter'
    };
  var data = [trace1];
  Plotly.newPlot('plotlyDiv1', data, layout);

So, in this case: for x==1, plot 3 y-values at position 1,3 and 5. This should then result in an area filled plot with 3 traces: 1 trace where all points are on y==1, 1 trace where all points are on y==3 and one trace with all points on y==5.

Of course I could do that with 3 traces but due to existing code, it would be a lot easier to do it the way as described above. Is something like that possible?

No, you have to replicate the X array for each trace.

Alright, that’s what I suspected. Thank you for your quick answer.