Unconquerable p 2022-08-04 16:39 采纳率: 90.9%
浏览 247
已结题

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的哪里出了问题?(急用求解决)

  • 写回答

1条回答 默认 最新

  • Yeats_Liao Java领域优质创作者 2022-08-05 09:55
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 8月13日
  • 已采纳回答 8月5日
  • 创建了问题 8月4日

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站