Matplotlib运行失败

代码:


import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.animation as animation
    
if __name__ == '__main__':
    #调试部分
    print("program running")
    x1=[1,2,3]
    y1=[3,4,5]
    z1=[6,7,8]
    fig = plt.figure()
    ax = Axes3D(fig,auto_add_to_figure=False)
    fig.add_axes(ax)
    ax.legend(loc='best')
    ax.axis('off')
    def demo(num):
        print("running")
        a=tmin_+((tmax_-tmin_)/tnums)*(num%tnums)
        print(a,(tmax_-tmin_)/tnums,num)
        ax.scatter(x1[:num],y1[:num],z1[:num], c = 'r')
    print(1)
    ani = animation.FuncAnimation(fig, demo,fargs=[],
                                  interval=0)
    fig.show()
    print("end...")

结果未显示图像(一闪而过)
运行结果:(console里的内容)


1
end...
No handles with labels found to put in legend.
C:\Users\*****\AppData\Roaming\Python\Python39\site-packages\matplotlib\animation.py:973: UserWarning: Animation was deleted without rendering anything. This is most likely unintended. To prevent deletion, assign the Animation to a variable that exists for as long as you need the Animation.
  warnings.warn(

Animation的哪里出了问题?(急用求解决)

No handles with labels found to put in legend. 没有在图例中找到带标签的句柄。
ax.legend()是为了展示标签,你的ax.legend()方法没加label参数
ax.legend(loc='best', label="xx")