How to update animation of 3D arrows in matplotlib

I am trying to play the left plot of this animation in python using matplotlib.

enter image description here

I can generate vector arrows using the 3D quiver function, but since I read here , it is not possible to set the arrow lengths. So, my plot does not look quite right:

enter image description here

So the question is: how do I create multiple 3D arrows of different lengths? It is important to note that I can generate them in such a way that I can easily change for each frame of the animation?

Here is my code so far, with a not very promising 3D quiver:

import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d

ax1 = plt.subplot(111,projection='3d')

t = np.linspace(0,10,40)

y = np.sin(t)
z = np.sin(t)
line, = ax1.plot(t,y,z,color='r',lw=2)

ax1.quiver(t,y,z, t*0,y,z)
plt.show() 
+2
source share
2

, , , mpl_toolkits/mplot3d/axes3d.py, . matplotlib, axes3d.py , script,

norm = math.sqrt(u ** 2 + v ** 2 + w ** 2)

norm = 1

( . "" .) , axes3d.py , mpl,

from . import art3d
from . import proj3d
from . import axis3d

from mpl_toolkits.mplot3d import art3d
from mpl_toolkits.mplot3d import proj3d
from mpl_toolkits.mplot3d import axis3d

, ( , , , SO).

enter image description here

:

import numpy as np
import matplotlib.pyplot as plt
import axes3d_hacked

ax1 = plt.subplot(111,projection='3d')
plt.ion()
plt.show()

t = np.linspace(0,10,40)

for index,delay in enumerate(np.linspace(0,1,20)):
    y = np.sin(t+delay)
    z = np.sin(t+delay)

    if delay > 0:
        line.remove()
        ax1.collections.remove(linecol)

    line, = ax1.plot(t,y,z,color='r',lw=2)
    linecol = ax1.quiver(t,y,z, t*0,y,z)

    plt.savefig('images/Frame%03i.gif'%index)
    plt.draw()

plt.ioff()
plt.show()

, , . ...

EDIT: matplotlib 3D- .

+2

ax.quiever - length. , .

MPL-

0

All Articles