Hello! I’m really enjoying the new Plotly Python library, it’s great.
I don’t know if this is a daft question but I wonder if there is a function to delete all traces from my chart, to revert it to an empty FigureWidget?
I’m setting up a scatterplot with several different datasets that I would like to compare. I start with an empty FigureWidget and add scatter traces using ‘fig.add_scatter’ using a dropdown list to choose which of my datasets I’d like to load to compare.
What I’d really like to be able to do is add a button which removes all my added traces and returns it to an empty plot so that a user can reset the chart and start over choosing traces to compare, but I can’t work out how to do this.
I’ve tried just making a button that runs go.FigureWidget() again but this doesn’t do anything, my chart looks the same!
Thanks @jmmease, That was a simple but a brilliant solution.
I was using three dropdowns to plot traces (corresponding to the selected dropdown values) in a graph object. When the dropdown values are cleared i.e when no values are selected, I wanted the graph object to remove all traces but retain the layout properties (x-axis, yaxis range, ticks etc.).
Various solutions I had tried before either removed the Graph object in its entirety or placed an empty graph object. The layout would also disappear. Aesthetics wise this was an eyesore.
So, I came across your solution. Within the callback, I initialised one graph object with valid data and the desired layout. In the next step, I removed all the traces while retaining the layout.
fig.data = 
I will further look for ways to finetune it further.
But thanks for the solution.