From 5fcf4bdb16198458f95e323acbe77ebf9dbae388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Mon, 20 Apr 2020 10:51:33 +1200 Subject: [PATCH] Switch to jshtml to render animations --- tools_matplotlib.ipynb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools_matplotlib.ipynb b/tools_matplotlib.ipynb index 5d99f4e..f23c5e0 100644 --- a/tools_matplotlib.ipynb +++ b/tools_matplotlib.ipynb @@ -1087,8 +1087,8 @@ }, "outputs": [], "source": [ - "%matplotlib nbagg\n", - "import matplotlib.animation as animation" + "import matplotlib.animation as animation\n", + "matplotlib.rc('animation', html='jshtml')" ] }, { @@ -1125,7 +1125,8 @@ " return line,\n", "\n", "line_ani = animation.FuncAnimation(fig, update_line, frames=100, fargs=(data, line), interval=67)\n", - "plt.show()" + "plt.close()\n", + "line_ani" ] }, { @@ -1133,7 +1134,7 @@ "metadata": {}, "source": [ "# Saving animations to video files\n", - "Matplotlib relies on 3rd-party libraries to write videos such as [FFMPEG](https://www.ffmpeg.org/) or `mencoder`. In this example we will be using FFMPEG so be sure to install it first." + "Matplotlib relies on 3rd-party libraries to write videos such as [FFMPEG](https://www.ffmpeg.org/) or [ImageMagick](https://imagemagick.org/). In this example we will be using FFMPEG so be sure to install it first. To save the animation to the GIF format, you would need ImageMagick." ] }, {