Legend Grouped Annotation Plotly

Hi,

I have a markdown document in which I use plotly to generate line plots in a report.
As I have multiple samples and 2 groups I only want the legend to hgihlight the groups
“Index” but without loosing the “Sample” names when pointing on the lines in the plot.

Data:
|Sample|Coverage|value|Index|
|DE04NG|1|99.6228|N|
|DE05NG|2|99.5319|N|
|DE09NG|10|98.5131|N|
|DE10NG|20|94.5059|N|
|DE11NG|30|85.2039|N|
|DE15NG|40|70.8523|N|
|DE16NG|1|99.858|Y|
|DE20NG|2|99.8129|Y|
|DE21NG|10|99.4932|Y|
|DE26NG|20|98.5794|Y|
|DE27NG|30|96.3532|Y|
|DE31NG|40|92.2396|Y|
|DE32NG|50|86.3037|Y|

This is the code I have used so far:

plot_ly(data = data, x =~Coverage, y=~value, color =~Index, name =~Sample,
mode = “lines”) %>%
layout(yaxis=list(title=“Fraction”), xaxis=list(title=“Coverage”),
autosize=T, showlegend=T, title=“Report” )

So I want to get rid off the long legend and instead I prefer a small legend where only two groups “Index” (Y/N) are shown but dont want to loose the “Sample” names when pointing on the lines.

I have attached the data and a screenshot of the plot. Appreciate your help very much. Best, Peter

line_plot

Just found the solution. By adding “hoverinfo” I could get the lines in the plot correctly annotatedt.