Grouped line plots in Plotly R: how to control line color?
<p>I have a bunch of 'paired' observations from a study for the same subject, and I am trying to build a spaghetti plot to visualize these observations as follows:</p>

<pre><code>library(plotly)
df &lt;- data.frame(id = rep(1:10, 2),
                 type = c(rep('a', 10), rep('b', 10)),
                 state = rep(c(0, 1), 10),
                 values = c(rnorm(10, 2, 0.5), rnorm(10, -2, 0.5)))
df &lt;- df[order(df$id), ]
plot_ly(df, x = type, y = values, group = id, type = 'line') %&gt;%
  layout(showlegend = FALSE)
</code></pre>

<p>It produces the correct plot I am seeking. But, the code shows each grouped line in own color, which is really annoying and distracting. I can't seem to find a way to get rid of colors.</p>

<p>Bonus question: I actually want to use <code>color = state</code> and actually color the sloped lines by that variable instead.</p>

<p>Any approaches / thoughts?</p>