Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Multiple streaming plots for one window

I was wondering whether it is possible to have 4 subplots streaming on one window. Right now I can only get a combination of two subplots to be streaming at the same time. Is there a way to increase the number of subplots? Here is my code so far.

           var trace1 = {

x: [],
y: [],
type: ‘lines+markers’
};

var trace2 = {
x: [],
y: [],
xaxis: ‘x2’,
yaxis: ‘y2’,
type: ‘lines+markers’
};

var trace3 = {
x: [],
y: [],
xaxis: ‘x3’,
yaxis: ‘y3’,
type: ‘lines+markers’
};

var trace4 = {
x: [],
y: [],
xaxis: ‘x4’,
yaxis: ‘y4’,
type: ‘lines+markers’
};

var data = [trace1, trace2, trace3, trace4];

var layout = {
xaxis: {domain: [0, 0.45]},
yaxis: {domain: [0, 0.45]},
xaxis4: {
domain: [0.55, 1],
anchor: ‘y4’
},
xaxis3: {
domain: [0, 0.45],
anchor: ‘y3’
},
xaxis2: {domain: [0.55, 1]},
yaxis2: {
domain: [0, 0.45],
anchor: ‘x2’
},
yaxis3: {domain: [0.55, 1]},
yaxis4: {
domain: [0.55, 1],
anchor: ‘x4’
}
};

function rand() {
return Math.random();
}
Plotly.newPlot(‘Dashboard’, data, layout,{displaylogo: false, displayModeBar: true});
var interval = setInterval(function() {
var update = {
x: [[rand()], [rand()]],
y: [[rand()], [rand()]]
}
Plotly.extendTraces(‘Dashboard’, update, [0,1])
}, 1000);

You’re almost there

Plotly.newPlot(‘Dashboard’, data, layout,{displaylogo: false, displayModeBar: true});
var interval = setInterval(function() {
  var update = {
    x: [[rand()], [rand()], [rand()], [rand()]],
    y: [[rand()], [rand()], [rand()], [rand()]]
  }
Plotly.extendTraces(‘Dashboard’, update, [0,1, 2, 3])
}, 1000);

should do the trick.