Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotly Hiding the trace initially

Tags:

plotly

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.

like image 921
KansaiRobot Avatar asked Jul 30 '26 23:07

KansaiRobot


1 Answers

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

like image 130
KansaiRobot Avatar answered Aug 03 '26 12:08

KansaiRobot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!