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

Defining default/starting frame with Plotly Express Animation

I have two plotly express plots (one animated choropleth map and one animated barplot, see for which I’d like to display the last frame (the latest date) as the default/starting value.

So far, I’ve been able to change the default slider value, but this does not update the default frame in the plot (which remains the first frame). Is there a way I can force the plot to update after setting the slider value?

Example code in this notebook:

Thanks! :slight_smile:

Hi @jeremym,

This line of code updates your fig data and displays the last frame:

1 Like

I also had to update the hovertemplate so that it displayed the correct date.

mtlmap_fig.update_traces(z=mtlmap_fig.frames[-1].data[0].z, hovertemplate=mtlmap_fig.frames[-1].data[0].hovertemplate)