我有一个data.frame列,这是一种颜色,我希望将它应用于绘制图表中的行
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)
但这只会导致默认颜色
提前致谢