Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

How do you hide traces initially in Plotly Express?

I have a visualization that has many categories (100+) contained within a single column. I want to display them on plotly express so I pass that column as color= column_w_100+_category.

However, I don’t want to show all of them together at once at the start. Ideally, it should be an empty chart in the beginning that you can slowly click on the legend to populate it.

Plotly sort of teaches you the way to do it with plotly.go, but it is impractical to add 100 trace one by one so I did it with plotly express. I searched online and it seems like there is no discussion about how to do this at plotly express.

Alternatively, I can just use for loop add trace for plotly.go, but it will take a long time to redevelop the charting code…

import plotly.graph_objects as go

fig = go.Figure()

    x=[1, 2, 3, 4, 5],
    y=[1, 2, 3, 4, 5],

    x=[1, 2, 3, 4, 5],
    y=[5, 4, 3, 2, 1],

So all of the go attributes can be applied to any figure (created with go or px) with the update_traces methods on fig. So you can do something like:

1 Like