I have a column of a data.frame which is a color and am looking to apply this to lines in a plotly chart
library(plotly)
library(dplyr)
df <- tibble(team=c("A","A","A","A","B","B","B","B"),
season=c(2000,2000,2001,2001,2000,2000,2001,2001),
game=c(1,2,1,2,1,2,1,2),
points=c(0,3,1,1,1,2,0,1),
theColor=c("red","red","red","red","grey","grey","blue","blue"))
df %>%
group_by(team,season) %>%
plot_ly(x=~game,y=~points,color=~theColor) %>%
add_lines() %>%
layout(showlegend=FALSE)
But this just results in default colors
Thanks in advance