其他分享
首页 > 其他分享> > matplotlib 旋转的箭头3d动画实现记录

matplotlib 旋转的箭头3d动画实现记录

作者:互联网

完整代码如下:

    import math
    import time
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d import Axes3D  # 空间三维画图
    x=y=z=u=v=w=0
    v=-1


    fig = plt.figure()
    ax = Axes3D(fig)
    arrow = ax.quiver(x, y, z, u, v, w, length=0.1, normalize=True)
    # plt.show() # don't use this sentence and it shall work
    for i in range(100):
        print(i)
        plt.cla() # plt.clf()
        u = math.cos(math.pi / 6 * i)
        v = math.sin(math.pi / 6 * i)
        arrow = ax.quiver(x, y, z, u, v, w, length=0.1, normalize=True)
        plt.draw()
        plt.pause(.001)

效果如下:(他会转)
在这里插入图片描述

标签:动画,plt,quiver,matplotlib,箭头,ax,import,math,3d
来源: https://blog.csdn.net/qq_34342853/article/details/120383126