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

Add trace not working

i am trying to use plotly to add various traces, but this is not wokring

mat <- array(rnorm(1000), dim=c(10, 10, 10))

my_x <- c(1:10)
timetaken <- rep(1,10)
p<-plot_ly(y=timetaken, x=my_x , type=“scatter”, mode=“markers+lines”)

for(i in 5:6){
for(j in 4:7){
timetaken <- mat[i,my_x,j]
p<-add_trace(p, y=~timetaken, x=~c(1:10),type=“scatter”,mode=“markers+lines”)

rather than adding all the traces only final trace is added

Hey @divanshu

All the traces are plotted … you’ve just plotted the same data for traces 1 through 8.

Toggle the traces in the legend to check. You can also use plotly_json(p) to inspect the data.