Hi,
Iām plotting some traces with mode=ālinesā and showlegend=True, but then also adding traces for the final data point of each line with mode=āmarkersā and showlegend=False. Hereās an example:
trace_data = pd.DataFrame({'base': [0, 1, 2, 3, 4],
'trace1': [1, 2, 3, 4, 5],
'trace2': [1.5, 1.9, 2, 3.9, 6],
'trace3': [2, 1, 3.3, 4.4, 4.5],
'trace4': [0, 3, 2, 1, 3]})
trace_colors = plotly.colors.qualitative.D3
color_idx = 0
fig = go.Figure()
for trace in ['trace1', 'trace2', 'trace3', 'trace4']:
# Perform a lot of data wrangling in Pandas here...
fig.add_trace(go.Scatter(x=trace_data['base'],
y=trace_data[trace],
mode='lines',
marker=dict(color=trace_colors[color_idx % len(trace_colors)]),
name=trace))
fig.add_trace(go.Scatter(x=[trace_data['base'].iloc[-1]],
y=[trace_data[trace].iloc[-1]],
mode='markers',
marker=dict(color=trace_colors[color_idx % len(trace_colors)]),
showlegend=False))
color_idx += 1
fig.show()
The trouble is, when I double-click on one of the legend entries in order to isolate that trace, the end-markers for all traces are still visible:
This is actually much, much more distracting with my actual dataset. Iām also plotting the traces in that loop because with my actual data thereās a lot of pre-processing I need to do within the loop before adding the trace.
Is there a better way to add these end-point markers? And if not, how can I isolate a trace by double-clicking the legend when Iāve got these hidden legend markers?
Thanks!!!