Hide legend trace in plot with multiple types

Hi @Mirk0_98 ,

changing from

trace_contour = px.density_contour(df, x=trait1, y=trait2, color='Species').update_layout(showlegend=False).select_traces()

to

trace_contour = px.density_contour(df, x=trait1, y=trait2, color='Species').update_traces(showlegend=False).select_traces()

Produces the desired output.

That is, because the information of showlegend is stored in the trace. Here you can see this exemplary for the first trace:

traces = px.density_contour(df, x=trait1, y=trait2, color='Species').select_traces()
print(next(traces))

Histogram2dContour({
    'contours': {'coloring': 'none'},
    'hovertemplate': ('Species=Adelie<br>Culmen Lengt' ... '}<br>count=%{z}<extra></extra>'),
    'legendgroup': 'Adelie',
    'line': {'color': '#636efa'},
    'name': 'Adelie',
    'showlegend': True,
    ...
    ...
1 Like