Traces of previous frame data is appearing in the current frame data and All traces are not displayed in the respective frames

I am facing two problems in animation using python API. I am using figures as dictionary. Plotly version is 4.1.1
problem-1: Previous frame traces data is appearing in the current frame traces data and i want to see always current frame traces data only.
problem-2: All traces data in a frame is not displayed and it always takes number of traces from data dictionary only and number of traces in the plot are not varied though frame as more or less traces from the data traces dictionary.
Ex:- 1st frame has 5 list of traces as a data.
2nd frame has 4 list of traces as a data.
3rd frame has 10 list of traces as a data.
when i plot this scenario, the output always(in the all the frames) shows 5 traces only in the plot, the actual expectation is 2nd frame should show 4 traces and 3rd frame should be 10 traces. The plot data is changing from one frame to another frame but it is not changing number of traces.

Please provide your insight to resolve this issue

In the following pictures, it can be observed from the frames, number of traces in the frames are not updated though data is changing as explained in the example above