Unconquerable p 2022-08-04 08:39 采纳率: 91.7%
浏览 285
已结题

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 01:55
    关注

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

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

报告相同问题?

问题事件

  • 系统已结题 8月12日
  • 已采纳回答 8月5日
  • 创建了问题 8月4日
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部