title: Converting ggplot to plotly - one line in different colors
body: <p>I want to have plot where one line in drawn in different colors as in example below:</p>
  
  <pre><code>test_data &lt;-
      data.frame(
          var0 = 100 + c(0, cumsum(runif(49, -20, 20))),
          var1 = 150 + c(0, cumsum(runif(49, -10, 10))),
          date = seq(as.Date("2002-01-01"), by="1 month", length.out=100)
      )
  
  plot &lt;- ggplot(test_data, aes(x = date)) + 
      geom_line(aes(y = var0, group = 1, colour = c(rep(c("a", "b"), each = 25), rep("a", 50)))) + 
      geom_line(aes(y = var1, colour = "var1"))
  plot
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/nAv4e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nAv4e.png" alt="enter image description here"></a></p>
  
  <p>I what to have the same plot in plotly or some other interactive library in R (so that the lables with some data could be displayed when moving the mouse on some specific line/point). When I use <code>ggplotly</code> I get something like this</p>
  
  <pre><code>library(plotly)
  ggplotly(plot)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Zsldf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zsldf.jpg" alt="enter image description here"></a></p>
  
  <p>Do you know how to combine red and green line in one line (in ggplot it is done through <code>group=1</code> parameter)?</p>