I need to generate an animating Heatmap but not working?

I have an RL system I want to deploy on streamlit. However in this system, I need to update a heatmap to position my agent and end goal. The plot is deployed fine but the plot does not animate, I have no idea what to do.
Please guide me on this.
Here is the update code.

fig,ax = plt.subplots(1,1,figsize = (15,15))
ax.imshow(State)
ax.set_xticks(np.arange(0,n_cols))
ax.set_xticks(np.arange(-.5, n_cols, 1), minor=True)
ax.set_yticks(np.arange(-.5, n_rows, 1), minor=True)
ax.grid(which = 'minor',color='w', linestyle='-', linewidth=2)
figure = st.pyplot(fig,clear_figure=True)
#To create figure above code

        
def plot(State,s,fig,ax,windy,n_rows,n_cols,figure):
  State[s[0],s[1]] = 1
  ax.imshow(State)
  ax.set_xticks(np.arange(0,n_cols))
  ax.set_xticks(np.arange(-.5, n_cols, 1), minor=True)
  ax.set_yticks(np.arange(-.5, n_rows, 1), minor=True)
  ax.grid(which = 'minor',color='w', linestyle='-', linewidth=2)
  figure.pyplot(fig=fig, clear_figure=False)
  if s[1] not in windy:
    State[s[0],s[1]] = 0
  else:
    State[s[0],s[1]] = 0.4

this is how I run my code in a loop 
time.sleep(1)
plot(State, s, fig, ax, windy_columns,n_rows,n_cols,figure)
#All in a loop

Please guide me what I am doing wrong as it is like a similar solution I saw for animating matplotlib figure