How to define colour of a point for a factor column

Perhaps, this article or this forum discussion will help. Without the data, it is hard to demonstrate how to apply to your situation. Here is an example using mtcars.

plot_ly(
  mtcars,
  x = mpg,
  y = wt,
  group = factor(cyl),
  mode = "markers",
  marker = list(
    color = factor(mtcars$cyl,labels=c("red","purple","blue"))  
  ) 
)