Python 属性错误:';numpy.int32';对象没有属性';获得"佐德"';在matplotlib中使用FuncAnimation时

Python 属性错误:';numpy.int32';对象没有属性';获得"佐德"';在matplotlib中使用FuncAnimation时,python,matplotlib,animation,Python,Matplotlib,Animation,只有当我在下面的代码中设置Blit=True时,我才会得到错误,当我设置Blit=False时,它才起作用。不幸的是,我需要Blit=True,因为它使动画更加平滑(至少我是这么认为的)。这里怎么了?我看到其他线程也有相同的错误消息,但它并不是专门针对matplotlib之类的东西 import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import numpy as np fig, ax =

只有当我在下面的代码中设置Blit=True时,我才会得到错误,当我设置Blit=False时,它才起作用。不幸的是,我需要Blit=True,因为它使动画更加平滑(至少我是这么认为的)。这里怎么了?我看到其他线程也有相同的错误消息,但它并不是专门针对matplotlib之类的东西

import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import numpy as np

fig, ax = plt.subplots()

ax.axis('off')

circle_red1 = plt.Circle((1, 1), 1, color='red')
circle_red2 = plt.Circle((0, 0), 1, color='red')
circle_red3 = plt.Circle((0, 1), 1, color='red')
circle_red4 = plt.Circle((1,0), 1, color='red')

ax.add_artist(circle_red1)
ax.add_artist(circle_red2)
ax.add_artist(circle_red3)
ax.add_artist(circle_red4)

circle_white = plt.Circle((0.5, 0.5), 0.1, color='white')

ax.add_artist(circle_white)

fig.set_size_inches(5, 5)

def update(i, fig, ax):
    while i <= 50:
        circle_white = plt.Circle((0.5, 0.5), i/100, color='white')
        ax.add_artist(circle_white)

        return fig, ax, i

    while 50 < i <= 100:
        circle_red1 = plt.Circle((1, 1), i/1000, color='red')
        circle_red2 = plt.Circle((0, 0), i/1000, color='red')
        circle_red3 = plt.Circle((0, 1), i/1000, color='red')
        circle_red4 = plt.Circle((1, 0), i/1000, color='red')

        ax.add_artist(circle_red1)
        ax.add_artist(circle_red2)
        ax.add_artist(circle_red3)
        ax.add_artist(circle_red4)

        return fig, ax, i

anim = FuncAnimation(fig, update, frames=np.arange(0, 100, 1), interval=10, blit=True, repeat=False, fargs=(fig, ax))

plt.show()
导入matplotlib.pyplot作为plt
从matplotlib.animation导入FuncAnimation
将numpy作为np导入
图,ax=plt.子批次()
ax.轴(“关闭”)
圆圈=plt.圆圈((1,1),1,color='red')
圆圈2=plt.circle((0,0),1,color='red')
圆圈3=plt.circle((0,1),1,color='red')
圆圈4=plt.circle((1,0),1,color='red')
ax.添加艺术家(圆圈红色1)
ax.添加艺术家(圆圈红色2)
ax.添加艺术家(圆圈红色3)
ax.添加艺术家(圆圈红色4)
圆形=圆形((0.5,0.5),0.1,颜色=白色)
ax.添加艺术家(圆形或白色)
图设置尺寸英寸(5,5)
def更新(i、图、ax):

当i如果
blit
True
时,更新函数必须返回修改或创建的所有美工人员的列表,请参见:

def更新(i,图,ax):

我非常感谢你!不再抛出错误,现在看起来更加平滑。
def update(i, fig, ax):
    while i <= 50:
        circle_white = plt.Circle((0.5, 0.5), i/100, color='white')
        ax.add_artist(circle_white)

        return [circle_white]

    while 50 < i <= 100:
        circle_red1 = plt.Circle((1, 1), i/1000, color='red')
        circle_red2 = plt.Circle((0, 0), i/1000, color='red')
        circle_red3 = plt.Circle((0, 1), i/1000, color='red')
        circle_red4 = plt.Circle((1, 0), i/1000, color='red')

        ax.add_artist(circle_red1)
        ax.add_artist(circle_red2)
        ax.add_artist(circle_red3)
        ax.add_artist(circle_red4)

        return [circle_red1, circle_red2, circle_red3, circle_red4]