plotly incorrectly draws lines scatter (and scatter3d) plots.
Consider the following minimal example:
df = data.frame(x=c(1,2,3,4,5,6),
y=c(1,1,2,2,3,3),
t=c("A","A","B","B","A","A"))
plot_ly(df, type="scatter", x=x, y=y, color=t, group=y, mode="lines")
The output is:

In the correct plots only the horizontal segments colored according to t column are expected; also no 1,2,3 entries in the legend, A and B sorted either alphabetically or by their appearance in the data frame.