Как добавить живой график Matplotlib на мою HTML-страницу?

#html #python-3.x

#HTML #python-3.x

Вопрос:

Как я могу добавить живой график matplotlib на мою HTML-страницу?

 from psutil import cpu_percent
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation


print(cpu_percent())


frame_len = 200
y = []
def animate(i):
    y.append(cpu_percent())

    if len(y) <= frame_len:
        plt.cla()
        plt.plot(y, 'r', label = 'Real-Time Cpu')

    plt.tight_layout()

ani = FuncAnimation(plt.gcf(), animate, interval= 1000)
#grp = plt.show()