Black Lives Matter. Please consider donating to Black Girls Code today.

Update 3D line plot with multiple line

so I have plotted a 3d plot with this data, with a,b,c some array
data=[
{
type: ‘scatter3d’,
mode : “lines+markers”,
x: a,
y: b,
z: c},
{

Now lets say I have the data for 5 different 3d line lets say like [a1,b1,c1] , [a2,b2,c2]…[a5,b5,c5] . all a,b,c 's are arrays. How do I update the plot to now show those 5 different 3d plot. I think I have to use the restyle command i.e https://plot.ly/javascript/plotlyjs-function-reference/#plotlyrestyle but I can’t figure out the update variable .

by doing:

Plotly.restyle(gd, {
  x: [
    [/* new x coords for 1st trace */],
    ....
    [/* new x coords for nth trace */]
  ],
  y: [
    [/* new y coords for 1st trace */],
    ....
    [/* new y coords for nth trace */]
  ],
  z: [
    [/* new z coords for 1st trace */],
    ....
    [/* new z coords for nth trace */]
  ]
})

I’m using this
Plotly.restyle(graph, {‘x’: [
[1,2,3],
[2,3,4],
[3,4,5]],
‘y’: [
[3,4,5],
[5,6,7],
[3,4,5],],
‘z’: [
[3,5,6],
[7,8,9],
[2,4,8]]});

but this just plot one line not 3.

by line do you mean a line trace or a line segment?

I mean like 3 seperate lines not connected to each other.

So , it turns out if I start the plot with N line then only I can update N line data like this

var data=[]
for (var i = 0; i < 46; i++) {
  data.push({
        type: 'scatter3d',
        mode : "markers+lines",
        x: a,
        y: b,
        z: c,
        marker : {
          size : 1.9,
          color : "#1f77b4"
        },
        line :{
          color : '#ff7f0e'
        },
        hoverinfo : "x+y+z"}
    )}