Black Lives Matter. Please consider donating to Black Girls Code today.

How to efficiently Restyle/Update/Modify plot containing frames?

Dear all,

I read about plotly functionality to call Plotly.restyle or Plotly.relayout instead of creating a whole new plot, whenever the data or layout attributes change. (see https://plot.ly/javascript/plotlyjs-function-reference/#plotdivdata-and-plotdivlayout)
However, I am using an animated plot containing frames and was wondering, if something similar exists, which is applied to frames or if I have to replot the whole plot, when for example a frame is added.
Is functionality, applied to the data object such as addTraces extended and applied to all frames or do I explicitly have to set it?

Thanks for your help.

Best regards,
Lisa

1 Like

Not at all. restyle, addTraces and other **Traces methods only apply to the traces appearing on the graph at that time.

Yes. Calling Plotly.addFrames with the same frame name will replace the frame data. See https://codepen.io/etpinard/pen/ayRyxj?editors=1010 for an example.

Thanks a lot for your reply @etienne. And thank you for pointing me towards the add frames function…somehow I had overlooked it existed.

No worries! There’s this piece https://plot.ly/javascript/animations/ on the topic, if you’re looking for more info.