[Python] How to show a matplotlib animation in Colab without also showing the plot?

Discussão em 'Python' iniciado por Stack, Agosto 5, 2025.

  1. Stack

    Stack Membro Participativo

    In a Google Colab notebook, I'm building a matplotlib animation and I'm displaying it as HTML5 video. The last lines of my script are:

    # ...
    anim = animation.ArtistAnimation(plt.gcf(), frames,
    interval=250, blit=True, repeat=False)
    HTML(anim.to_html5_video())


    The video looks alright, but then I get another image of the plot displayed below the video (showing the same thing as the last frame of the video). If I call plt.close() at the end, neither the plot nor the video gets displayed. How can I show the video without showing the plot?

    Continue reading...

Compartilhe esta Página