我想使用以下代码在Jupyter Notebook中进行简单的matplotlib animation绘制:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_classification
import matplotlib.animation as animation
X,y_train = make_classification(n_samples=100,n_features=2,n_informative=2,n_redundant=0,n_clusters_per_class =1,shift=0,class_sep=1.9)
fig = plt.figure(figsize=(10,8))
ax = fig.add_subplot(1,1,1)
def update(num,X,y_train):
ax.scatter(X[:num,0],X[:num,1])
ani = animation.FuncAnimation(fig,update,frames=10,interval=1000,fargs=[X,y_train])
plt.show()
我也尝试了不使用$ matplotlib内联,但是它仍然无法正常工作。 有人可以帮我吗?