Plotly Hiding the trace initially

Viewed 285

I know by reading the documentation that it is possible to hide some traces initially.

The docs give us this example

import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(go.Scatter(
    x=[1, 2, 3, 4, 5],
    y=[1, 2, 3, 4, 5],
))

fig.add_trace(go.Scatter(
    x=[1, 2, 3, 4, 5],
    y=[5, 4, 3, 2, 1],
    visible='legendonly'
))

fig.show()

That is good. However I am creating a plot with several scatter plots done in a loop so I need to set some visible and some not. For invisible it is visible='legendonly' but what can I write for visible? (I know that not writing anything does the trick but since it is going to be a loop, it would be nice to set it to something.

1 Answers

I just found out that the three possible values for visible are True, False and 'legendonly'

Related