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

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日

悬赏问题

  • ¥20 西门子S7-Graph,S7-300
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改