Plot gif in the streamlit app

I tried to plot a gif on my streamlit site, but it doesn’t generate anything. It doesn’t give any error, it just keeps the environment empty as if nothing had been run in the code.

Below I left the piece of my code responsabel by the plot of the gif.

I appreciate any help.

graph, = plt.plot([], [], color="gold", markersize=3, label='Tempo: 0 s')
        L = plt.legend(loc=1)

plt.close()  # Não mostra a imagem de fundo

def animate(i):
     lab = 'Tempo: ' + str(round(dt*i * (rs_sun / 2.0) * 3e-5 , -int(math.floor(math.log10(abs(dt*(rs_sun / 2.0)*3e-5)))))) + ' s'
     graph.set_data(x[:i], y[:i])
     L.get_texts()[0].set_text(lab)  # Atualiza a legenda a cada frame
     return graph,

skipframes = int(len(x)/200)
if skipframes == 0:
     skipframes = 1

ani1 = animation.FuncAnimation(fig, animate, frames=range(0,len(x),skipframes), interval=30, blit = True, repeat = False)
        
plt.show()