I am trying to create a simple matplotlib animation in a Jupyter notebook running inside vscode.
%matplotlib notebook
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
fig, ax = plt.subplots()
line, = ax.plot([]) # A tuple unpacking to unpack the only plot
ax.set_xlim(0, 2*np.pi)
ax.set_ylim(-1.1, 1.1)
def animate(frame_num):
y = np.sin(x + 2*np.pi * frame_num/100)
line.set_data((x, y))
return line
anim = FuncAnimation(fig, animate, frames=100, interval=5)
plt.show()
However, no figure appears after running the cell, just the green tick symbol.
Using Jupyter extension, both release version v2022.11.1003412109 and pre-release version v2023.1.1003441034.
Is it possible to get the animated matplotlib figure to work inside Vscode Jupyter notebook?

import from Ipython.display import HTMLto animate, I added the following code in vscode and ran your code. The vscode extension isv2022.11.1003412109.#plt.show();from IPython.display import HTML;plt.close();HTML(anim.to_html5_video())