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

Issue updating histogram2d via Plotly.animate

Hi all,

I’m trying to make a histogram2d plot that updates dynamically using the Plotly.animate api. That is, I have some arrays of x and y data that I periodically add points to, and I then want to update a histogram2d plot of these data. For a scatter plot this works perfectly and I end up with a nice animation. But for some reason, for histogram2d this doesn’t work – the plot remains static.

I’ve set up a minimal non-working example here:

Essentially, this creates a new plot, and then calls Plotly.animate in a requestAnimationFrame loop. Running the example shows that the data is updated, for some reason the plot doesn’t update.

Does anybody know why this wouldn’t work, or what I am doing wrong? Any help is appreciated!

With best wishes,

Commenting out redraw: false seems to get things working:

Awesome, Etienne! That does the trick. Now I’ll need to dive into the docs/code to understand what that does, but it’s a great start.