擅长:python、mysql、java
<p>从matplotlib 1.4.x开始,箭袋现在可以在3d中绘图</p>
<p><a href="https://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#quiver" rel="nofollow noreferrer">quiver3d_demo.py in the examples directory</a>:</p>
<pre><code>from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
x, y, z = np.meshgrid(np.arange(-0.8, 1, 0.2),
np.arange(-0.8, 1, 0.2),
np.arange(-0.8, 1, 0.8))
u = np.sin(np.pi * x) * np.cos(np.pi * y) * np.cos(np.pi * z)
v = -np.cos(np.pi * x) * np.sin(np.pi * y) * np.cos(np.pi * z)
w = (np.sqrt(2.0 / 3.0) * np.cos(np.pi * x) * np.cos(np.pi * y) *
np.sin(np.pi * z))
ax.quiver(x, y, z, u, v, w, length=0.1)
plt.show()
</code></pre>
<p><img src="https://i.stack.imgur.com/PfOt1.png" alt="enter image description here"/></p>