title: How can I apply a color lookup table in R plotly
body: <p>For data involving sports teams, I want to apply consistent custom colors from a lookup table for any charts I produce. This is my current effort</p>
  
  <pre><code>library(tidyverse)
  library(plotly)
  
  lookup &lt;- tibble(team=c("Dolphins","Sharks","Minnows"), color_id =c("dodgerblue","red","black"))
  
  data &lt;- tibble(team =c("Dolphins","Sharks","Minnows","Sharks"),V1=c(1:4),V2=c(4:1))
  
  df &lt;- data %&gt;% 
      left_join(lookup)
  
  
  colors &lt;- lookup$color_id
  
  plot_ly(df, x= ~ V1, y= ~ V2, color = ~ color_id, name =  ~ team, colors = colors) 
  
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rVCY4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rVCY4.png" alt="Output"></a></p>
  
  <p>As you can see, the legend does not identify the colors appropriately. e.g Dolphins should be dodgerblue</p>
  
  <p>Thanks in advance</p>