0

I'm attempting to have Plotly choose unique colors for all lines that are being created on a chart. Currently, there are 5 lines, but in the future there could be more or less. I thought something like line = ~list(color = c("red", "purple")), would work, but I can't get even two lines to be different colors in the chart.

Code:

fig <- plot_ly(theDataframe, x = ~start_date, y = ~score, type = 'scatter', mode = 'lines+markers',
                   marker = ~list(color="purple"),
                   line = ~list(color = c("red", "purple")),
                   source="master_results",
                   hoverinfo = 'text', 
Bob
  • 1,344
  • 3
  • 29
  • 63
  • 2
    It would be easier to help you if you provide a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data. – stefan Oct 01 '21 at 19:29

1 Answers1

0

Try using discrete colors with colorscale as described here, using a qualitative color sequence (see a list here).

line =list(colorscale = 'Accent')

If you need more colors than the ones available in the built-in palettes, see this QA to generate a custom color palette with a large number of distinctive colors.

julien.leroux5
  • 969
  • 7
  • 17